这是我的场景:
a.xml
-----
<beans> <!-- no 'profile' attribute -->
<bean id="a" class="com.a.A"/>
</beans>
b.xml
-----
<beans > <!-- no 'profile' attribute -->
<bean id="b" class="com.b.B"/>
</beans>
c.xml
-----
<beans ><!-- no 'profile' attribute -->
<bean id="c" class="com.c.C"/>
</beans>
<beans profile="dev">
<rabbit:connection-factory id="connectionFactory"
host="x.x.net" username="a" port="xxxx"
password="a" />
....
....
</beans>
目标:
当我在本地运行我的应用程序时,我想加载 a.xml、b.xml 中的所有 bean 和 C.xml 中的所有 bean,但配置文件“dev”除外
当我在开发环境中运行我的应用程序时,我想加载 a.xml、b.xml 中的所有 bean 和 C.xml 中的所有 bean
我将 -Dspring.profiles.active=!dev 设置为 JVM 系统参数。问题是它没有加载其他 bean。
任何想法,我该如何处理这种情况?
这应该按您的预期运行,在本地期间根本没有传入任何配置文件(等待您导入所有 3 个 xml 文件)。只有在使用 dev 配置文件启动 spring 时才会加载带有“dev”的 beans 元素。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句