gpt4 book ai didi

java - Spring 配置文件 : Which element should be parsed?

转载 作者:行者123 更新时间:2023-11-29 04:48:59 25 4
gpt4 key购买 nike

我在 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>元素将被解析考虑到:prof1prof2 配置文件已激活。

貌似一直选这个<beans profile="prof1" > , 但不确定为什么不选择另一个 <beans profile="!prof1" > .我可以转告它总是会选择 <beans>没有感叹号?

最佳答案

Javadoc for Profile指出

If a given profile is prefixed with the NOT operator (!), the annotated component will be registered if the profile is not active

(spring-beans XSD 对 XML bean 定义的声明相同,但更难阅读。)

据我了解,只有 prof1 会针对带有 profile="!prof1" 的 beans 元素进行查看。您还激活 prof2 与此 bean 定义无关。

关于java - Spring 配置文件 : Which <beans> element should be parsed?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36149354/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com