我想将其添加到Applation.Properties文件中My.list.of.string={{1,2},{2,3}}并将该值加载到Java类中。我该怎么做呢?我试过了@VALUE(“#{‘${my.list.of.string}’.Split(‘,’)}”)个人分发名单myList;但它并没有起作用。
ewm0tg9j1#
一年前,我通过创建一个配置类解决了这个问题。
配置YAML:
my: servers: - dev.example.com - another.example.com
配置类:
@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; } }
1条答案
按热度按时间ewm0tg9j1#
一年前,我通过创建一个配置类解决了这个问题。
配置YAML:
配置类: