Spring Initializr (http://start.spring.io/)을 사용하여 Spring Boot (0.5.0.BUILD-SNAPSHOT) 응용 프로그램을 만들었습니다. 단일 @RestController, 단일 CrudRepository 인터페이스 및 단일 @Entity 클래스가 추가되었습니다.Spring Boot 응용 프로그램에 spring-boot-starter-security를 추가하면 'entityManagerFactory'또는 'persistenceUnitName'이 필요합니다.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
응용 프로그램 클래스가 기본 포함되어 있습니다 : 내 메이븐 POM은 다음과 같은 종속성이 포함
@ComponentScan
@EnableAutoConfiguration
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
간단한 응용 프로그램이 오류없이 실행을,하지만 난 관리를 확보하기 위해 POM에 봄 보안을 추가하기로 결정 엔드 포인트는 :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
이제 응용 프로그램이 시작되지 않습니다, 나는 다음과 같은 얻을 :
java.lang.IllegalArgumentException가 : 나는 스프링 부팅 스타터 보안 종속성을 제거 할 때 '의 EntityManagerFactory'또는 'persistenceUnitName이'
Caused by: java.lang.IllegalArgumentException: 'entityManagerFactory' or 'persistenceUnitName' is required
at org.springframework.orm.jpa.JpaTransactionManager.afterPropertiesSet(JpaTransactionManager.java:304)
at org.springframework.orm.jpa.JpaTransactionManager.<init>(JpaTransactionManager.java:141)
at org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.transactionManager(JpaBaseConfiguration.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:166)
... 18 more
필요합니다 응용 프로그램은 잘하지만 보안이 사용하지 않고 실행됩니다. 오류는 무엇을 의미합니까? 응용 프로그램은 이미 Spring Security를 사용하지 않고 JPA와 Hibernate를 사용합니다.
보안 설정의 일부 bean이 일부 JPA 종속성의 초기 인스턴스 생성을 강제하는 것 같습니다. 나는 전에이 특정 문제를 본 적이 없으며, JPA 및 보안을 사용하는 많은 응용 프로그램을 작성했습니다. 이전에 결코 보지 못한 이상한 주문 문제가있을 수 있습니다. 나는 그것을 재현 할 수 있는지 살펴볼 것입니다. 대답이있는 사람은 누구나 자유롭게 의견을 말할 수 있습니다. –