简体   繁体   English

春季在security-context.xml中使用applicationContext中的bean

[英]Spring use bean from applicationContext in security-context.xml

I have following entries 我有以下条目

web.xml: web.xml:

  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml /WEB-INF/spring-security.xml</param-value>
</context-param>
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

applicationContext: applicationContext:

<bean id="myUserDAO" class="no.java.UserDAOImpl">
    <property name="DataSource" ref="myDataSource"/>
</bean>

in spring-security.xml i have following entry: 在spring-security.xml中,我输入以下内容:

<beans:bean id="myUserDetailsService" class="no.java.SimpleUserDetailsService" >
            <property name="UserDAO" ref="myUserDAO" />
 </bean>

and now i'm gettting following error 现在我正在跟随错误

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 13 in XML document from ServletContext resource [/WEB-INF/spring-security.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 13; columnNumber: 56; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'property'.
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)

as far as i understand i should be getting something like bean myUserDAO undefined or something similar, but i'm not. 据我了解,我应该得到未定义的bean myUserDAO之类的东西或类似的东西,但是我没有。 I'd be really greatful for any help as i'm enjoying this error for quite a few hours right now. 我非常感谢您提供任何帮助,因为我现在已经花了几个小时享受这个错误。

Your XML is not well formed, this 您的XML格式不正确,这

<beans:bean id="myUserDetailsService" class="no.java.SimpleUserDetailsService" >
    <property name="UserDAO" ref="myUserDAO" />
</bean>

should be 应该

<beans:bean id="myUserDetailsService" class="no.java.SimpleUserDetailsService" >
    <beans:property name="UserDAO" ref="myUserDAO" />
</beans:bean>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Jersey尝试Spring Security我的security-context.xml文件出了什么问题? - Trying Spring Security with Jersey What is wrong with my security-context.xml file? Spring 3 applicationContext-security-JDBC.xml有bean:bean不是bean? - Spring 3 applicationContext-security-JDBC.xml has beans:bean not bean? 将密码存储在xml security-context.xml或数据库中的最佳实践? - Best practice to store password in xml security-context.xml or database? 创建ApplicationContext作为Spring bean(通过其他应用程序上下文) - Create ApplicationContext as Spring bean (by other application context) Spring ApplicationContext,包含来自应用程序中不同项目的多个上下文xml文件 - Spring ApplicationContext with multiple context xml files from different projects in an application Spring安全配置错误/WEB-INF/applicationContext.xml,并且没有名为springSecurityFilterChain的bean - Spring security configuration error /WEB-INF/applicationContext.xml and there's no bean called springSecurityFilterChain 根据 applicationContext.xml 中的条件将过滤器 bean 添加到 spring-security 过滤器链 - Add a filter bean to spring-security filter chain based on condition in applicationContext.xml 无法打开ServletContext资源[/src/main/resources/security-context.xml] - Could not open ServletContext resource [/src/main/resources/security-context.xml] 如何在Spring中通过ApplicationContext即时直接使用bean - How to use bean directly by ApplicationContext instant in Spring 在Spring @Configuration中引用applicationContext.xml bean - Referring applicationContext.xml bean in Spring @Configuration
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM