Spring boot



A special starter that provides useful maven defaults. It also provides a dependency-management section so that you can omit version tags for common dependencies. Spring-boot-starter-parent includes a few of maven goal such as repackage and run goal to start application:

mvn spring-boot:run

Other features can be found from here.



Overview Spring Boot

  • Automatic configuration
  • Starter dependencies
  • Command line interface
  • The actuator



Spring boot read the properties based on the sequence which overwrite from top down sequence. Eg, default properties can get overwritten by any 1-7 options.

  1. Command line argues
  2. JNDI lookup
  3. JVM system properties
  4. OS system environment variable
  5. external application.properties (subdir /config or same level path as application)
  6. internal application.properties (not the default path, package named “config” or root classpath)
  7. Property sources specific by @PropertySource
  8. default properties


Profile and properties file

application.properties file are serve as default properties file. If you’d like to have properties file based on different profile setting. Let’s say production, staging, development. All you need to do is create the properties file with this pattern. application-{profile}.properties. And activate the profile during your application startup.



With annotated @ConfigurationProperties, your bean class it has injected a value (setter injection) with prefixed define by your choice, Let’s say ‘hello‘. It similar like using @Value inject from properties files.

1) First you’ve need to add the dependencies.


2) Example, in controller annotated @ConfigurationProperties. We can specific the location file with attribute as well.
(more practically, use it as a component class and inject to your controller)

public class HelloWorldController {

  private String world;
  public void setWorld(String world) {
     this.world = world;
  @RequestMapping(method = RequestMethod.GET)
  public String index(Model model) {
    model.addAttribute("world", world);
    return "helloworld";

3 Properties file

hello.world=Hello World

4. Your html

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<title>Reading List</title>
<link rel="stylesheet" th:href="@{/css/style.css}"></link>

  <h2>Hello World</h2>
  <p th:text="${world}">Text to be replace</p>


Web Resource Version Random Hash

# Appended random hash string behind the resources files.


Web Resource Version Append



Web Resource Compression GZIP



Web Context Path

From the application.properties modified the follow properties. After that you’ll able access with http://web:8080/app




Actuator is a feature provided by spring boot to let you inspect in your spring boot application. Actuator provide service such as monitoring and metric to the application. There are several way to gain the data either through the remote endpoint with REST, remote shell and JMX.


GET /autoconfig

A report describing about autoconfig condition either pass or failed.


GET /configprops

A report to show how exactly a bean injected with configuration properties


Get /beans

A report to show all the beans in relationship


Get /dump

Snapshoot dump of thread activity


Get /health

An application health check. It can be configured from application.properties with showing details or without.



Health Indicator

We can create custom health check by implement HealthIndicator interface. It will output to actuator.

public class WebserviceHealIndicator implements HealthIndicator 
  public Health health() {
    boolean good = true;
    //implement logic ping your remote
    if (true) {
      return Health.up().withDetail("Webservice up", "Connection alive").build();
    } else {
      return Health.down().withDetail("Webservice down","Connection lost").build();


Actuator Info

By default, actuator expose nothing on the info. But you can provide the information with the following properties. Alternative, by using @[value]@ to refer the properties set from maven pom.xml







And more others like 

  • Get /env or /env/{name}
  • Get /info
  • Get /mappings
  • Get /metrics or /metrics/{name}
  • Get /shutdown
  • Get /trace


Interface upon startup

  • CommandLineRunner
  • ApplicationRunner


Create Filter

  • Create filter and annotated with @Component or @WebFilter
  • Annotation with @ServletComponentScan.

Customize actuator path

From the application.properties, modified the value. http://localhost:8080/privat/aconfig




Spring boot

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.