I want to add this to application.properties file
my.list.of.strings={{1,2},{2,3}}
And load this value into Java class. How do I do this?
I have tried
@Value("#{'${my.list.of.strings}'.split(',')}")
private List myList;
but it didnot work...
I want to add this to application.properties file
my.list.of.strings={{1,2},{2,3}}
And load this value into Java class. How do I do this?
I have tried
@Value("#{'${my.list.of.strings}'.split(',')}")
private List myList;
but it didnot work...
I solved it a year ago by creating a config class.
Config yaml:
my:
servers:
- dev.example.com
- another.example.com
Config class:
@Profile("servers")
@Component
@ConfigurationProperties(prefix = "my")
@NoArgsConstructor
@AllArgsConstructor
public class PackageConfig {
private List<String> servers = new ArrayList();
public List<String> getServers() {
return this.servers;
}
public void setServers(List<String> servers) {
this.servers = servers;
}
}