【发布时间】:2014-12-25 09:33:00
【问题描述】:
我想用 Spring Boot 外部化我的配置,但我想继续部分使用我的 xml 上下文。
我的主类 SpringServerApplication.java :
@Configuration
@PropertySources(value = {@PropertySource("classpath:/application.properties")})
public class SpringServerApplication {
public static void main(String[] args) throws Exception {
SpringApplication.run(new Object[] {
SpringServerApplication.class, "classpath:ApplicationContextServer.xml" }, args);
}
}
我将我的配置放在 application.properties 中。
在 ApplicationContextServer.xml 中,我想使用一些像这样的参数:${user}。
但它不起作用。提前感谢您的帮助。
【问题讨论】:
-
错误?例外?乍一看我会说,不需要属性源注释,因为这是默认值
-
也许可以试试@ImportResource 而不是显式参数
-
是例外,因为变量没有被它们的值替换。 @ImportResource 出现同样的错误。
标签: java spring spring-boot