For example, I have file DataSourceConfig.java
package com.apress.demo;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@ConfigurationProperties(prefix = "jdbc")
public class DataSourceConfig {
private String driver;
private String url;
private String username;
private String password;
@Override
public String toString() {
return "DataSourceConfig [driver=" + driver + ", url=" + url + ", username=" + username + "]";
}
public String getDriver() {
return driver;
}
public void setDriver(String driver) {
this.driver = driver;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
How to do this notice?
It is just a reminder that configuration properties will not be available until you Make changes and annotation processor is re-run
You can enable annotation processors in IntelliJ via the following:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
Configuring the Annotation Processor
and add anatation @Configuration