JavaSpring概要文件:应该解析哪个<beans>元素?
我在spring上下文中有以下配置:
<beans profile="!prof1" >
<security:authentication-manager id="authenticationManager" erase-credentials="true">
<security:authentication-provider ref="1" />
<security:authentication-provider ref="2" />
<security:authentication-provider ref="3" />
</security:authentication-manager>
</beans>
<beans profile="prof1" >
<security:authentication-manager id="authenticationManager" erase-credentials="true">
<security:authentication-provider ref="0" />
<security:authentication-provider ref="1" />
<security:authentication-provider ref="2" />
<security:authentication-provider ref="3" />
</security:authentication-manager>
</beans>
在分析<beans>
元素时会考虑以下问题:
prof1和prof2配置文件被激活
看起来它总是选择这个<beans profile="prof1" >
,但不确定为什么不选择另一个<beans profile="!prof1" >
。我可以转告它总是选择<beans>
而不带感叹号吗
# 1 楼答案
如果您的活动配置文件是prof1和prof2,则以下配置文件将处于活动状态
# 2 楼答案
该Javadoc for Profile声明:
(对于XMLBean定义,spring-beans XSD声明了相同的内容,但更难阅读。)
据我所知,对于带有profile=“!prof1”的bean元素,只查看prof1。同时激活prof2与此bean定义无关