小编nas*_*000的帖子

根据.properties文件中的属性导入Spring配置文件

在我的Spring xml配置中,我试图让这样的东西起作用:

<beans>

   <import resource="${file.to.import}" />

   <!-- Other bean definitions -->

</beans>
Run Code Online (Sandbox Code Playgroud)

我想根据属性文件中的属性决定导入哪个文件.我知道我可以使用System属性,但我无法在启动时向JVM添加属性.

注:PropertyPlaceHolderConfigurer将无法正常工作.在运行任何BeanFactoryPostProcessor之前解析导入.import元素只能解析System.properties.

有人有一个简单的解决方案吗?我不想开始子类化框架类等等......

谢谢

java configuration spring

34
推荐指数
4
解决办法
4万
查看次数

标签 统计

configuration ×1

java ×1

spring ×1