[SPRING] java.lang.NoSuchMethodError : Parsistence.spi.PersistenceUnitInfo.getValidationMode () Ljavax / persistence / ValidationMode;
SPRINGjava.lang.NoSuchMethodError : Parsistence.spi.PersistenceUnitInfo.getValidationMode () Ljavax / persistence / ValidationMode;
봄 데이터 예제를 쓰고 있습니다. 이것은 나의 spring.xml이다.
<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/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
<context:component-scan base-package="com.currencyconverter.entity" />
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="database.properties" />
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${driver.name}" />
<property name="url" value="${database.url}" />
<property name="username" value="${database.username}" />
<property name="password" value="${database.password}" />
</bean>
<bean id="currencyRateImpl" class="com.currencyconverter.dao.CurrencyRateImpl">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.currencyconverter.entity" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">create-drop</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
그리고 이들은 내 pom.xml의 종속성입니다.
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>3.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>3.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.5.0.RELEASE</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jpa</artifactId>
<version>2.0.2</version>
</dependency>
</dependencies>
persistence.xml을 사용하지 않았습니다. 다음과 같은 예외가 발생합니다.
코드에 문제가 있습니다. 종속성 및 버전이 맞습니다 .OR persistence.xml은 봄 3.2에 필요합니다. 그렇다면 포함 할 내용은 무엇입니까?
해결법
-
==============================
1.이 오류는 JPA 1 API가 도입 되었기 때문에 발생하지만 getValidationMode 메소드는 JPA 2 이후에만 존재합니다.
이 오류는 JPA 1 API가 도입 되었기 때문에 발생하지만 getValidationMode 메소드는 JPA 2 이후에만 존재합니다.
따라 가기 대신
<dependency> <groupId>javax.persistence</groupId> <artifactId>persistence-api</artifactId> <version>1.0.2</version> </dependency>
예를 들어 Hibernate에 의해 제공되는 것을 사용할 수있다 :
<dependency> <groupId>org.hibernate.javax.persistence</groupId> <artifactId>hibernate-jpa-2.0-api</artifactId> <version>1.0.1.Final</version> </dependency>
from https://stackoverflow.com/questions/22167945/java-lang-nosuchmethoderror-javax-persistence-spi-persistenceunitinfo-getvalida by cc-by-sa and MIT license
'SPRING' 카테고리의 다른 글
[SPRING] 스프링 보안에서 새로운 PasswordEncoder를 사용하는 방법 (0) | 2018.12.23 |
---|---|
[SPRING] Spring WebSockets의 경로 변수 @SendTo 매핑 (0) | 2018.12.23 |
[SPRING] @ 거래를 할 곳은 어디입니까? 인터페이스 사양 또는 구현에서? (0) | 2018.12.22 |
[SPRING] 기능별 접근 방식은 좋은 방법입니까? [닫은] (0) | 2018.12.22 |
[SPRING] 스프링 부트 - 관리 형이 아님 (0) | 2018.12.22 |