0

我有以下条目

网页.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>

应用上下文:

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

在 spring-security.xml 我有以下条目:

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

现在我得到以下错误

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)

据我了解,我应该得到类似 bean myUserDAO undefined 或类似的东西,但我没有。我会非常感谢任何帮助,因为我现在已经享受这个错误好几个小时了。

4

1 回答 1

3

您的 XML 格式不正确,这

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

应该

<beans:bean id="myUserDetailsService" class="no.java.SimpleUserDetailsService" >
    <beans:property name="UserDAO" ref="myUserDAO" />
</beans:bean>
于 2013-01-22T14:51:01.580 回答