【发布时间】:2017-06-04 21:35:49
【问题描述】:
在我的目标文件夹中,有 2 个文件夹,lib 和 conf。所有的properties文件都放在conf文件夹中,jars放在libfolder中。
在spring boot之前,我们在spring.xml中使用如下配置来使用@value
<context:property-placeholder location="classpath*:*.properties"/>
在java代码中:
@Value("${name}")
private String name;
但是在 spring boot 中,我不知道如何在 java 代码中做同样的事情。
我试过了,但没用
@Configuration
@PropertySource(value = "classpath:aaa.properties")
public class AppConfig {
@Bean
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
}
【问题讨论】:
标签: spring spring-boot properties configuration