匹配的通配符是严格的,但是没有为元素'property'找到声明

时间:2015-02-09 08:43:32

标签: java spring-mvc

我遇到弹簧配置问题,如下所示。

 <?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <!-- DispatcherServlet Context: defines this servlet's request-processing 
        infrastructure -->

    <!-- Enables the Spring MVC @Controller programming model -->
    <annotation-driven />

    <!-- Handles HTTP GET requests for /resources/** by efficiently serving 
        up static resources in the ${webappRoot}/resources directory -->
    <resources mapping="/resources/**" location="/resources/" />

    <!-- Resolves views selected for rendering by @Controllers to .jsp resources 
        in the /WEB-INF/views directory -->
    <beans:bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <beans:property name="prefix" value="/WEB-INF/views/" />
        <beans:property name="suffix" value=".jsp" />
    </beans:bean>

    <context:component-scan base-package="com.novcode.date" />

    <beans:bean name="employee" class="com.novcode.date.Employee"
        scope="request"></beans:bean>
    <beans:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="org.sql.Driver" />
        <property name="url" value="jdbc:mysql://localhost:3306/securepassspring" />
        <property name="username" value="root" />
        <property name="password" value="spuser" />
    </beans:bean>

    <beans:bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="packagesToScan">
            <value>com.novcode.date</value>
        </property>
        <property name="configurationClass">
            <value>org.hibernate.cfg.AnnotationConfiguration</value>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.MYSQL5Dialect</prop>
                <prop key="hibernate.show_sql">true</prop>
            </props>
        </property>
    </beans:bean>
</beans:beans>

我面临的主要问题是,我正在用红色说过Cross标记 Error Image

我确信我已经多次对这个错误进行了交叉检查,我也确定我必须对xsd做一些事情,但我不确定是否与春天的初学者相同。

我的Maven如下:This is spring version。请不要担心属性中的数据可以编辑相同的内容。

请帮忙, 感谢。

1 个答案:

答案 0 :(得分:0)

由于你的命名空间有前缀bean xmlns:beans="http://www.springframework.org/schema/beans“,你需要用来解决错误。如果你声明你的命名空间是这样的,xmlns="http://www.springframework.org/schema/beans",那么你不需要在任何地方定义bean。希望这有帮助。