java - Spring-Hibernate-JPA-Spring-Data-Maven-JSF应用Tomcat启动错误

标签 java spring hibernate maven jpa

我正在使用 Tomcat 8 在 Eclipse-Mars 中启动 Spring-Hibernate-JPA-Spring-Data-Maven-JSF 应用程序。尝试启动服务器时遇到启动错误,并且我尝试过解决这个问题一个多星期了,我想是时候寻求帮助了!

下面是一些来自控制台的 Tomcat 错误打印输出:

  ...
    08:47:10.900 [localhost-startStop-1] INFO  o.s.b.f.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
  ...
    08:47:10.981 [localhost-startStop-1] ERROR o.s.web.context.ContextLoader - Context initialization failed
    org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 23 in XML document from ServletContext resource [/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 23; columnNumber: 67; cvc-elt.1: Cannot find the declaration of element 'beans'.
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:399) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    ...
SEVERE: One or more listeners failed to start. Full details will be found in the appropriate container log file
    May 10, 2016 8:47:15 AM org.apache.catalina.core.StandardContext startInternal
    SEVERE: Context [/SilentHomeCemetery_Maven] startup failed due to previous errors
    May 10, 2016 8:47:15 AM org.apache.catalina.core.ApplicationContext log
    INFO: Closing Spring root WebApplicationContext
    08:47:15.465 [localhost-startStop-1] INFO  o.s.w.c.s.XmlWebApplicationContext - Closing Root WebApplicationContext: startup date [Tue May 10 08:47:10 EDT 2016]; root of context hierarchy
    08:47:15.472 [localhost-startStop-1] WARN  o.s.w.c.s.XmlWebApplicationContext - Exception thrown from LifecycleProcessor on context close
    java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: Root WebApplicationContext: startup date [Tue May 10 08:47:10 EDT 2016]; root of context hierarchy
        at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:414) [spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]

这是我的 web.xml 文件:

<?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
      <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
      </listener>
      <listener>
        <listener-class>
            org.springframework.web.context.request.RequestContextListener
        </listener-class>
      </listener>  
      <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>
                /WEB-INF/applicationContext.xml           
            </param-value>
      </context-param>
      <context-param>  
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
      </context-param>
      <context-param>
            <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
            <param-value>/WEB-INF/springsecurity.taglib.xml</param-value>
      </context-param> 
      <!-- 
      <filter>
            <filter-name>springSecurityFilterChain</filter-name>
            <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        </filter>
        <filter-mapping>
            <filter-name>springSecurityFilterChain</filter-name>
            <url-pattern>/*</url-pattern>
      </filter-mapping>
       -->
       <filter>
            <filter-name>loginFilter</filter-name>
            <filter-class>com.kletus.silentHomeCemetery.filters.LoginFilter</filter-class>
       </filter>
       <filter-mapping>
        <filter-name>loginFilter</filter-name>
        <url-pattern>/faces/Admin/*</url-pattern>
       </filter-mapping>
       <filter>
            <filter-name>preventLoginFilter</filter-name>
            <filter-class>com.kletus.silentHomeCemetery.filters.PreventLoginFilter</filter-class>
       </filter>
       <filter-mapping>
        <filter-name>preventLoginFilter</filter-name>
        <url-pattern>/faces/index.xhtml</url-pattern> 
       </filter-mapping>   
      <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
      </servlet>

      <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>  
      <!-- Map these files with JSF -->   
        <url-pattern>/faces/*</url-pattern>
        <url-pattern>*.jsf</url-pattern>
        <url-pattern>*.faces</url-pattern>      
      </servlet-mapping>  

      <welcome-file-list>
        <welcome-file>index.xhtml</welcome-file>
        <welcome-file>/faces/index.xhtml</welcome-file>    
    </welcome-file-list>

     <context-param>
            <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
            <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
            <param-value>client</param-value>
        </context-param>

      <session-config>
        <session-timeout>30</session-timeout>
      </session-config>
    </web-app>

这是我的 applicationContext.xml 文件:

<?xml version="1.0" encoding="UTF-8"?>
<beans
       xmlns="http://www.springframework.org/schema/beans:beans"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"       
       xmlns:jee="http://www.springframework.org/schema/jee"
       xmlns:jpa="http://www.springframework.org/schema/data/jpa"
       xmlns:util="http://www.springframework.org/schema/util"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xsi:schemaLocation="
        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
        http://www.springframework.org/schema/jee 
        http://www.springframework.org/schema/jee/spring-jee.xsd
        http://www.springframework.org/schema/util 
        http://www.springframework.org/schema/util/spring-util.xsd
        http://www.springframework.org/schema/tx
               http://www.springframework.org/schema/tx/spring-tx.xsd       
               http://www.springframework.org/schema/data/jpa 
        http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">

    <!--    http://www.springframework.org/schema/data/jpa/spring-jpa-1.2.xsd"> -->

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

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

     <!-- Package needed to be scanned for annotation -->
    <context:component-scan base-package="spring"/>

    <!-- Use annotation for configuration-->
    <context:annotation-config/>
    <context:spring-configured/>

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

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="com.db2.jdbc.Driver" />
        <property name="url" value="jdbc:db2://localhost:50000/SLNTRURO" />
        <property name="username" value="<name>" />
        <property name="password" value="<password>" />
    </bean>    

    <!-- Hibernate 4 SessionFactory Bean definition -->
    <bean id="hibernate4AnnotatedSessionFactory"
        class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="annotatedClasses">
            <list>
                <value>com.kletus.silentHomeCemetery.model.jpa.GraveInfo</value>
                <value>com.kletus.silentHomeCemetery.model.jpa.Control</value>
                <value>com.kletus.silentHomeCemetery.model.jpa.Encrypted_lot_info</value>
                <value>com.kletus.silentHomeCemetery.model.jpa.EncryptedGraveInfo</value>
                <value>com.kletus.silentHomeCemetery.model.jpa.EncryptionKey</value>
                <value>com.kletus.silentHomeCemetery.model.jpa.LotInfo</value>                
                <value>com.kletus.silentHomeCemetery.model.jpa.Security</value> 
                <value>com.kletus.silentHomeCemetery.model.jpa.SilentHomeUser</value>    
                <value>com.kletus.silentHomeCemetery.model.jpa.UserRole</value> 
                <value>com.kletus.silentHomeCemetery.model.jpa.Role</value>           

            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.DB2Dialect
                </prop>
                <prop key="hibernate.show_sql">true</prop>
            </props>
        </property>
    </bean>    

    <bean id="UserDAO" class="com.kletus.silentHomeCemetery.DAO.UserDAO">
        <property name="sessionFactory"
            ref="hibernate4AnnotatedSessionFactory" />
    </bean>

    <context:component-scan base-package="com.kletus.silentHomeCemetery" />

    <bean id="persistenceUnitManager" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
    <!-- <property name="defaultPersistenceUnitName" value="nutrition-pu"/> -->
    <property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml"/>
    <property name="defaultDataSource" ref="dataSource" />
</bean>

    <!-- JPA -->
    <bean id="entityManager"
        class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="persistenceUnitManager" ref="persistenceUnitManager" />
        <property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
    </bean>

    <!-- jpaVendorAdapter (works in conjunction with the persistence.xml) -->
    <bean id="jpaVendorAdapter"
        class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
        <property name="database" value="${jpa.database}" />
        <property name="showSql" value="${jpa.showSql}" />
        <property name="databasePlatform" value="${jpa.dialect}" />
        <property name="generateDdl" value="${jpa.generateDdl}" />
        <property name="packagesToScan" value="com.kletus.silentHomeCemetery.model.jpa" />
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManager" />
        <property name="dataSource" ref="dataSource" />
    </bean>

    <bean id="persistenceAnnotation" class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />   

</beans>

这是我的 eclipselink-orm.xml 文件:

<?xml version="1.0" encoding="UTF-8"?>
    <entity-mappings version="2.5" xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/orm" 
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
            xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/orm http://www.eclipse.org/eclipselink/xsds/eclipselink_orm_2_5.xsd">
        <named-query name="Control.findAll">
            <query>select c from Control c</query>
        </named-query>
        <named-query name="Encrypted_lot_info.findAll">
            <query>select e from Encrypted_lot_info e</query>
        </named-query>
        <named-query name="EncryptedGraveInfo.findAll">
            <query>select e from EncryptedGraveInfo e</query>
        </named-query>
        <named-query name="EncryptionKey.findAll">
            <query>select e from EncryptionKey e</query>
        </named-query>
        <named-query name="LotInfo.findAll">
            <query>select l from LotInfo l</query>
        </named-query>        
        <named-query name="Security.findAll">
            <query>select s from Security s</query>
        </named-query>

        <named-query name="SilentHomeUser.findAll">
            <query>select u from SilentHomeUser u</query>
        </named-query>

        <named-query name="UserRole.findAll">
            <query>select z from UserRole z</query>
        </named-query>

        <named-query name="Role.findAll">
            <query>select r from Role r</query>
        </named-query>

        <entity class="com.kletus.silentHomeCemetery.model.jpa.Control" access="VIRTUAL">
            <table name="CONTROLS"/>
            <attributes>
                <id name="controlKey" attribute-type="int">
                    <column name="CONTROL_KEY"/>
                    <generated-value strategy="AUTO"/>
                </id>
                <basic name="dateLastBackup" attribute-type="java.util.Date">
                    <column name="DATE_LAST_BACKUP"/>
                    <temporal>DATE</temporal>
                </basic>
                <basic name="dateLastCompact" attribute-type="java.util.Date">
                    <column name="DATE_LAST_COMPACT"/>
                    <temporal>DATE</temporal>
                </basic>
            </attributes>
        </entity>
        <entity class="com.kletus.silentHomeCemetery.model.jpa.Encrypted_lot_info" access="VIRTUAL">
            <table name='"ENCRYPTED LOT INFO"'/>
            <attributes>
                <id name="eLotId" attribute-type="int">
                    <column name="E_LOT_ID"/>
                    <generated-value strategy="AUTO"/>
                </id>
                <basic name="eLot" attribute-type="String">
                    <column name="E_LOT"/>
                </basic>
                <basic name="eLotAddDate" attribute-type="String">
                    <column name="E_LOT_ADD_DATE"/>
                </basic>
                <basic name="eLotChgDate" attribute-type="String">
                    <column name="E_LOT_CHG_DATE"/>
                </basic>
                <basic name="eLotName" attribute-type="String">
                    <column name="E_LOT_NAME"/>
                </basic>
                <basic name="eLotNextOfKin" attribute-type="String">
                    <column name="E_LOT_NEXT_OF_KIN"/>
                </basic>
                <basic name="eLotNotes" attribute-type="String">
                    <column name="E_LOT_NOTES"/>
                </basic>
                <basic name="eLotOrigLotNbr" attribute-type="String">
                    <column name="E_LOT_ORIG_LOT_NBR"/>
                </basic>
                <basic name="eLotUniqId" attribute-type="String">
                    <column name="E_LOT_UNIQ_ID"/>
                </basic>
                <basic name="eUserName" attribute-type="String">
                    <column name="E_USER_NAME"/>
                </basic>
                <basic name="key" attribute-type="String">
                    <column name='"KEY"'/>
                </basic>
            </attributes>
        </entity>
        <entity class="com.kletus.silentHomeCemetery.model.jpa.EncryptedGraveInfo" access="VIRTUAL">
            <table name="ENCRYPTED_GRAVE_INFO"/>
            <attributes>
                <id name="eGraveId" attribute-type="int">
                    <column name="E_GRAVE_ID"/>
                    <generated-value strategy="AUTO"/>
                </id>
                <basic name="dateLastChanged" attribute-type="java.sql.Timestamp">
                    <column name="DATE_LAST_CHANGED"/>
                </basic>
                <basic name="eDeathDate" attribute-type="String">
                    <column name="E_DEATH_DATE"/>
                </basic>
                <basic name="eGraveAddDate" attribute-type="String">
                    <column name="E_GRAVE_ADD_DATE"/>
                </basic>
                <basic name="eGraveChgDate" attribute-type="String">
                    <column name="E_GRAVE_CHG_DATE"/>
                </basic>
                <basic name="eGraveDate" attribute-type="String">
                    <column name="E_GRAVE_DATE"/>
                </basic>
                <basic name="eGraveFuneralDirector" attribute-type="String">
                    <column name="E_GRAVE_FUNERAL_DIRECTOR"/>
                </basic>
                <basic name="eGraveLot" attribute-type="String">
                    <column name="E_GRAVE_LOT"/>
                </basic>
                <basic name="eGraveLotUniqId" attribute-type="String">
                    <column name="E_GRAVE_LOT_UNIQ_ID"/>
                </basic>
                <basic name="eGraveName" attribute-type="String">
                    <column name="E_GRAVE_NAME"/>
                </basic>
                <basic name="eGraveNbr" attribute-type="String">
                    <column name="E_GRAVE_NBR"/>
                </basic>
                <basic name="eGraveNotes" attribute-type="String">
                    <column name="E_GRAVE_NOTES"/>
                </basic>
                <basic name="eUserName" attribute-type="String">
                    <column name="E_USER_NAME"/>
                </basic>
                <basic name="encryptedGraveId" attribute-type="String">
                    <column name="ENCRYPTED_GRAVE_ID"/>
                </basic>
                <basic name="key" attribute-type="String">
                    <column name='"KEY"'/>
                </basic>
            </attributes>
        </entity>
        <entity class="com.kletus.silentHomeCemetery.model.jpa.EncryptionKey" access="VIRTUAL">
            <table name="ENCRYPTION_KEYS"/>
            <attributes>
                <id name="keyTracker" attribute-type="long">
                    <column name="KEY_TRACKER"/>
                    <generated-value strategy="AUTO"/>
                </id>
                <basic name="key" attribute-type="String">
                    <column name='"KEY"'/>
                </basic>
            </attributes>
        </entity>
        <entity class="com.kletus.silentHomeCemetery.model.jpa.LotInfo" access="VIRTUAL">
            <table name="LOT_INFO"/>
            <attributes>
                <id name="lotUniqId" attribute-type="int">
                    <column name="LOT_UNIQ_ID"/>
                    <generated-value strategy="AUTO"/>
                </id>
                <basic name="encryption_key" attribute-type="byte[]">
                    <column name='"ENCRYPTION KEY"'/>
                </basic>
                <basic name="lot" attribute-type="int">
                </basic>
                <basic name="lotAddDate" attribute-type="java.util.Date">
                    <column name="LOT_ADD_DATE"/>
                    <temporal>DATE</temporal>
                </basic>
                <basic name="lotChgDate" attribute-type="java.sql.Timestamp">
                    <column name="LOT_CHG_DATE"/>
                </basic>
                <basic name="lotName" attribute-type="String">
                    <column name="LOT_NAME"/>
                </basic>
                <basic name="lotNextOfKin" attribute-type="String">
                    <column name="LOT_NEXT_OF_KIN"/>
                </basic>
                <basic name="lotNotes" attribute-type="String">
                    <column name="LOT_NOTES"/>
                </basic>
                <basic name="lotOrigLotNbr" attribute-type="String">
                    <column name="LOT_ORIG_LOT_NBR"/>
                </basic>
                <basic name="userName" attribute-type="String">
                    <column name="USER_NAME"/>
                </basic>
            </attributes>
        </entity>
        <entity class="com.kletus.silentHomeCemetery.model.jpa.GraveInfo" access="VIRTUAL">
            <table name="GRAVE_INFO"/>
            <attributes>
                <id name="GraveId" attribute-type="int">
                    <column name="GRAVE_ID"/>
                    <generated-value strategy="AUTO"/>
                </id>
                <basic name="graveChgDate" attribute-type="java.sql.Timestamp">
                    <column name="GRAVE_CHG_DATE"/>
                </basic>
                <basic name="deathDate" attribute-type="java.sql.Timestamp">
                    <column name="DEATH_DATE"/>
                </basic>
                <basic name="graveAddDate" attribute-type="java.sql.Timestamp">
                    <column name="GRAVE_ADD_DATE"/>
                </basic>            
                <basic name="graveDate" attribute-type="String">
                    <column name="GRAVE_DATE"/>
                </basic>
                <basic name="graveFuneralDirector" attribute-type="String">
                    <column name="GRAVE_FUNERAL_DIRECTOR"/>
                </basic>
                <basic name="graveLot" attribute-type="String">
                    <column name="GRAVE_LOT"/>
                </basic>
                <basic name="graveLotUniqId" attribute-type="String">
                    <column name="GRAVE_LOT_UNIQ_ID"/>
                </basic>
                <basic name="graveName" attribute-type="String">
                    <column name="GRAVE_NAME"/>
                </basic>
                <basic name="graveNbr" attribute-type="String">
                    <column name="GRAVE_NBR"/>
                </basic>
                <basic name="graveNotes" attribute-type="String">
                    <column name="GRAVE_NOTES"/>
                </basic>
                <basic name="userName" attribute-type="String">
                    <column name="USER_NAME"/>
                </basic>
                <basic name="encryptKey" attribute-type="Byte">
                    <column name='"ENCRYPT_KEY"'/>
                </basic>
            </attributes>
        </entity>

        <embeddable class='com.kletus.silentHomeCemetery.model.jpa.UserRolePK"' access="VIRTUAL">
            <attributes>
                <basic name="userId" attribute-type="int">
                    <column name="USER_ID"/>
                </basic>
                <basic name="roleId" attribute-type="int">
                    <column name="ROLE_ID"/>
                </basic>
            </attributes>
        </embeddable>

        <entity class='com.kletus.silentHomeCemetery.model.jpa.UserRole"' access="VIRTUAL">
            <table name="USER_ROLES"/>
            <attributes>
                <id name="userId" attribute-type="int">
                    <column name="USER_ID"/>                
                </id>           
                <basic name="roleId" attribute-type="int">
                    <column name="ROLE_ID"/>
                </basic>
            </attributes>
        </entity>

        <entity class='com.kletus.silentHomeCemetery.model.jpa.Role"' access="VIRTUAL">
            <table name="ROLES"/>
            <attributes>
                <id name="roleId" attribute-type="int">
                    <column name="ROLE_ID"/>                
                </id>           
                <basic name="role" attribute-type="String">
                    <column name="ROLE"/>
                </basic>
            </attributes>
        </entity>       

        <entity class='com.kletus.silentHomeCemetery.model.jpa.SilentHomeUser"' access="VIRTUAL">
            <table name="SILENT_HOME_USER"/>
            <attributes>
                <id name="userId" attribute-type="int">
                    <column name="USER_ID"/>                
                </id>           
                <basic name="activeInd" attribute-type="int">
                    <column name="ACTIVE_IND"/>
                </basic>
                <basic name="fName" attribute-type="String">
                    <column name="FNAME"/>
                </basic>
                <basic name="mName" attribute-type="String">
                    <column name="MNAME"/>
                </basic>
                <basic name="lName" attribute-type="String">
                    <column name="LNAME"/>
                </basic>
                <basic name="password" attribute-type="String">
                    <column name="PASSWORD"/>
                </basic>
            </attributes>
        </entity>   

    </entity-mappings>

这是我的 spring-config.xml 文件:

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans:beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
         http://www.springframework.org/schema/beans/spring-beans.xsd        
          http://www.springframework.org/schema/aop 
          http://www.springframework.org/schema/aop/spring-aop.xsd
          http://www.springframework.org/schema/context 
          http://www.springframework.org/schema/context/spring-context.xsd
          http://www.springframework.org/schema/tx 
          http://www.springframework.org/schema/tx/spring-tx.xsd">

    <context:component-scan base-package="com.kletus.SilentHomeCemetery" />

    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="persistenceXmlLocation" value="classpath:/persistence.xml" />
        <!-- <property name="persistenceUnitName" value="userPersistenceUnit" /> -->
        <property name="dataSource" ref="dataSource" />
        <property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
        <property name="jpaDialect" ref="jpaDialect" />
    </bean>

    <bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
        <property name="database" value="DB2" />
        <property name="databasePlatform" value="org.hibernate.dialect.DB2Dialect" />
    </bean>

    <bean id="jpaDialect" class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />

    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory" />
        <property name="dataSource" ref="dataSource" />
        <property name="jpaDialect" ref="jpaDialect" />
    </bean>

    <tx:annotation-driven transaction-manager="transactionManager" />

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.ibm.db2.jcc.DB2Driver" />    
        <property name="url" value="jdbc:db2://localhost:50000/SLNTRURO:retrieveMessagesFromServerOnGetMessage=true;" />   

        <property name="username" value="<name>" />
        <property name="password" value="<password">"/>
    </bean>
</beans>

最佳答案

架构声明中有错误。

xmlns="http://www.springframework.org/schema/beans:beans"

应该是

xmlns="http://www.springframework.org/schema/beans"

这是 applicationContext.xml 的默认命名空间。日志清楚地表明了这一点。

lineNumber: 23; columnNumber: 67; cvc-elt.1: Cannot find the declaration of element 'beans'.

关于java - Spring-Hibernate-JPA-Spring-Data-Maven-JSF应用Tomcat启动错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37140300/

相关文章:

java - 在 Spring MVC 中,如何存储用户输入并稍后重现它?

spring - STS 启动极慢,加载 org.springsource.ide.eclipse.dashboard.ui

java - Spring 批处理 : Job dependencies

java - 组织.hibernate.HibernateException : save is not valid without active transaction

java - 升级 Firebase 后的 ClassMapper 警告

java - 将 list<map<string,object>> 转换为 POJO 类的对象

entity-framework - NHibernate 的三级缓存

java - Spring Hibernate 多对多关联与 transient 值

java - 为什么这个合并排序实现不起作用?

java - 正则表达式查找不区分大小写的用户名