-
Notifications
You must be signed in to change notification settings - Fork 41.5k
Closed
Description
Java 11.02
Spring Boot 2.3.3.RELEASE
I am having problem with application.properties file.
application.properties sometimes doesn't gets parsed when using Configuration List POJO. It seams to be some type of race condition. Not all the elements of list are parsed. The more fields I have in POJO the most likely it fail to parse application.properties. Most of the fields are String datatype in POJO
POJO:
public class ExternalRdbConfig {
private String name;
private int expirationInSeconds;
private String driver;
private String url;
private String user;
private String password;
public ExternalRdbConfig(){}
// getters, setters...
}
Configuration:
@Configuration
@EnableAutoConfiguration
@ConfigurationProperties(prefix = "external.resource")
public class ExternalConfig {
private final ArrayList<ExternalRdbConfig> rdb;
public ExternalConfig() {
this.rdb = new ArrayList<>();
}
public List<ExternalRdbConfig> getRdb() {
return rdb;
}
dump() {
.......
}
}
Controller
@RestController
public class EdpController {
@Autowired
private ExternalConfig externalConfig;
// Start only after all beans are loaded
@EventListener(ApplicationReadyEvent.class)
private void start() throws Exception {
externalConfig.dump();
}
}
application.properties
external.resource.rdb[0].name=Name0
external.resource.rdb[0].expirationInSeconds=0
external.resource.rdb[0].driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
external.resource.rdb[0].url=jdbc:sqlserver://10.102.130.197:1433;DatabaseName=R
external.resource.rdb[0].user=sa
external.resource.rdb[1].name=Name1
external.resource.rdb[1].expirationInSeconds=1
external.resource.rdb[1].driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
external.resource.rdb[1].url=jdbc:sqlserver://10.102.130.197:1433;DatabaseName=R
external.resource.rdb[1].user=sa
external.resource.rdb[2].name=Name2
external.resource.rdb[2].expirationInSeconds=2
external.resource.rdb[2].driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
external.resource.rdb[2].url=jdbc:sqlserver://10.102.130.197:1433;DatabaseName=R
external.resource.rdb[2].user=sa
external.resource.rdb[3].name=Name3
external.resource.rdb[3].expirationInSeconds=3
external.resource.rdb[3].driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
external.resource.rdb[3].url=jdbc:sqlserver://10.102.130.197:1433;DatabaseName=R
external.resource.rdb[3].user=sa
external.resource.rdb[4].name=Name4
external.resource.rdb[4].expirationInSeconds=4
external.resource.rdb[4].driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
external.resource.rdb[4].url=jdbc:sqlserver://10.102.130.197:1433;DatabaseName=R
external.resource.rdb[4].user=sa
Metadata
Metadata
Assignees
Labels
type: enhancementA general enhancementA general enhancement