把我所有的豆子放在不同的文件中
我正在使用 spring mvc 和 spring security。在我的 security-app-context.xml 中,我有:
<authentication-manager>
<authentication-provider user-service-ref="MyUserDetailsService"/>
</authentication-manager>
因此我需要在此 security-app-context.xml 文件中配置 MyUserDetailsService
。所以我添加了:
<beans:bean id="MyUserDetailsService"
class="my.web.authentication.GreenWheelsUserDetailsService">
<beans:property name="transactionManager" ref="transactionManager"/>
<beans:property name="userDao" ref="userDao"/>
</beans:bean>
但这导致我也将 transactionManager
和 userDao
bean 添加到该文件中!所以我补充道:
<beans:bean id="transactionManager" class="my.dataAccess.hibernate.HibernateTransactionManager"/>
<beans:bean id="userDao" class="my.dataAccess.hibernate.HibernateUserDao"/>
但现在我想为其他 DAO 添加另一个 beans。我更喜欢将所有 bean 放在不同的文件中,然后放在 security-app-context.xml 文件中。我该如何做到这一点并保持 authentication-manager
部分正确?
I am using spring mvc and spring security. In my security-app-context.xml I have:
<authentication-manager>
<authentication-provider user-service-ref="MyUserDetailsService"/>
</authentication-manager>
And therefore I need to configure MyUserDetailsService
in this security-app-context.xml file. So I added:
<beans:bean id="MyUserDetailsService"
class="my.web.authentication.GreenWheelsUserDetailsService">
<beans:property name="transactionManager" ref="transactionManager"/>
<beans:property name="userDao" ref="userDao"/>
</beans:bean>
But this cause me to add transactionManager
and userDao
beans to this file too! So I added:
<beans:bean id="transactionManager" class="my.dataAccess.hibernate.HibernateTransactionManager"/>
<beans:bean id="userDao" class="my.dataAccess.hibernate.HibernateUserDao"/>
But now I want to add anothr beans for other DAOs. I prefer to put all my beans in different file then the security-app-context.xml file. How do I do that and keep the authentication-manager
section correct?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用导入:
You can use import:
您可以使用 spring;将任何文件导入到您的 spring 安全文件中。
You can use the spring <beans:import resource="someotherfile.xml" /> to import any file into your spring security file.