티스토리 뷰
반응형
jpa 설정을 하고 테스트 코드를 돌려보니 해당 에러가 났다.
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository' defined in com.sgw.common.repository.UserRepository defined in @EnableJpaRepositories declared on DataSourceConfiguration: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class com.sgw.common.domain.User
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1788) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:609) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1367) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1287) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:885) ~[spring-beans-5.3.1.jar:5.3.1]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:789) ~[spring-beans-5.3.1.jar:5.3.1]
... 43 common frames omitted
Caused by: java.lang.IllegalArgumentException: Not a managed type: class com.sgw.common.domain.User
at org.hibernate.metamodel.internal.MetamodelImpl.managedType(MetamodelImpl.java:582) ~[hibernate-core-5.4.23.Final.jar:5.4.23.Final]
at org.hibernate.metamodel.internal.MetamodelImpl.managedType(MetamodelImpl.java:85) ~[hibernate-core-5.4.23.Final.jar:5.4.23.Final]
어노테이션 문제일까 싶어 여기저기 확인해보다
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
factory.setJpaVendorAdapter(jpaVendorAdapter());
factory.setPackagesToScan("com.swg.common.domain"); // <- 해당 부분에 오타가 났었다.ㅠ
factory.setDataSource(dataSource());
return factory;
}
factory.setPackagesToScan 해당 부분에 오타가 나서 @Entity 설정해준 클래스를 읽지 못하는 것이였다.
수정해주니 바로 동작되었다.ㅜ
추가적으로 LocalContainerEntityManagerFactoryBean 설정을 사용안한다면 @EntityScan으로 entity 클래스를 지정해주니 해당 어노테이션 설정을 확인해주면 될거같다.
반응형
'[JPA]' 카테고리의 다른 글
[JPA] 한글 깨짐 (0) | 2021.02.28 |
---|---|
[JPA] 기본키 매핑 (0) | 2020.12.22 |
[JPA] hibernate.hbm2ddl.auto 옵션 (0) | 2020.12.21 |
댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- 카멜 표기법
- JPA
- Visual Studio 2022
- 한글깨짐
- 확인창
- Thread
- gradle
- Executor
- sgw
- thread priority
- Mockito
- junit5
- java11
- IntelliJ
- Jenkins
- hot-deploy
- 파스칼 표기법
- JUnit
- Redis
- aspectj
- JetBrains Mono
- codepoint
- spring-security
- chmod
- spring
- java
- JAVA8
- jdk13
- jdk12
- ThreadPool
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
글 보관함