首页 > 解决方案 > spring 配置的 application-context.xml 文件中的错误

问题描述

application-context.xmlspring 框架的文件错误。它给出了参考文件的编译时错误

引用的文件包含错误(http://www.springframework.org/schema/beans/spring-beans.xsd)。有关更多信息,请右键单击问题视图中的消息并选择“显示详细信息...”

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

   
   <!-- Specifying base package of the Components like Controller, Service,
        DAO -->
    <context:component-scan base-package="com.common" />
    
    <!-- Getting Database properties -->
   <context:property-placeholder location="classpath:application.properties" />
   
   <mvc:annotation-driven />
    <!-- View Resolver -->
    <bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/" />
        <property name="suffix" value=".jsp" />
    </bean>
 
    <!-- step 1 : DataSource database / Datasource connection pool-->
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${database.driver}"></property>
        <property name="url" value="${database.url}"></property>
        <property name="username" value="${database.user}"></property>
        <property name="password" value="${database.password}"></property>
    </bean>
    
    <!--step 2 : Hibernate SessionFactory -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"></property>
        <property name="packagesToScan" value="com.common.objects"></property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">${hibernate.dialect}</prop>
                <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
                <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
                <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
            </props>
        </property>
    </bean>
   
    <!--step 3 : setting Hibernate Transaction manager-->
    <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>
    
    <bean id = "helloWorld" class = "com.tutorialspoint.HelloWorld">
      <property name = "message" value = "Hello World!"/>
    </bean>
</beans>

请建议。

标签: javaxmlspring

解决方案


推荐阅读