當我嘗試運行我的應用程序在Tomcat中7.0錯誤的persistence.xml JPA 2春天休眠3
我使用Hibernate 3 +彈簧+ MySQL的數據庫
我收到此異常:
Caused by: org.xml.sax.SAXParseException; lineNumber: 5; columnNumber: 19; cvc-complex-type.3.1: Value '2.0' of attribute 'version' of element 'persistence' is not valid with respect to the corresponding attribute use. Attribute 'version' has a fixed value of '1.0'.
的applicationContext.xml
<bean id="persistenceUnitManager"
class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
<property name="persistenceXmlLocation" value="classpath*:META-INF/classes/persistence_hibernate.xml"/>
<property name="defaultDataSource" ref="dataSource"></property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitManager" ref="persistenceUnitManager" />
</bean>
<tx:annotation-driven proxy-target-class="true" transaction-manager="transactionManager" />
<context:annotation-config></context:annotation-config>
persistence_hibernate.xml
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="UP_AB" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.show_sql" value="true" />
</properties>
</persistence-unit>
而且這是依賴我使用
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.2.8.RELEASE</version>
</dependency>
<dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.6.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.1.Final</version>
</dependency>
有一個與Tomcat的一個問題,我應該使用JBoss或類似的東西?
可以在Tomcat的使用JPA,你也可以在Tomcat上使用JSF,只需要一個或兩個Maven中的依賴關係。我有一個使用Spring,JPA,Primefaces的Tomcat應用程序。 – hiimjames 2014-12-07 17:38:51
我在它的依賴中沒有看到它們...你可以通過添加庫來調整tomcat,使它幾乎符合Java ee,但是爲什麼要使用tomcat呢?順便說一句,我已經廣泛使用的tomcat是4,我對它的調優不感興趣,但是感謝我添加了我已經省略的信息 – 2014-12-07 21:34:17