[Spring Boot2] Define your configuration properties

When we develop spring boot application, I think it’s very helpful that IDE gives popup suggestion when we configure application.yml, but if we define our own properties, IDE will not support this, even give us tips like “Cannot resolve configuration property “spring.application.log-path“.

So I checked spring document, and found ways to solve this.

1.Add spring dependency in your pom.xml

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-configuration-processor</artifactId>
</dependency>

2.Define your configuration class

@ConfigurationProperties(prefix = "spring.application")
@Data
public class ApiPropertyConfiguration {
    private String timezone;
    private String logPath;
}

Then try to type your properties in application.yml, I think you will get popup suggestions.