본문 바로가기

Server/Spring

[우당탕탕 개발일지] JPA Repository 오류, Not a managed type: class java.lang.Object

반응형
SMALL
java.lang.IllegalStateException: Failed to load ApplicationContext for [WebMergedContextConfiguration@31aa9
b01 testClass = com.example.springbootpart4.domain.order.OrderRepositoryTest, locations = [], classes = [com
.example.springbootpart4.SpringBootPart4Application], contextInitializerClasses = [], activeProfiles = [], proper
tySourceLocations = [], propertySourceProperties = ["org.springframework.boot.test.context.SpringBootTestCo
ntextBootstrapper=true"], contextCustomizers = [org.springframework.boot.test.context.filter.ExcludeFilterCont
extCustomizer@770d3326, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory
$DuplicateJsonObjectContextCustomizer@140c9f39, org.springframework.boot.test.mock.mockito.MockitoCo
ntextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@3738449f
, org.springframework.boot.test.autoconfigure.actuate.observability.ObservabilityContextCustomizerFactory$Di
sableObservabilityContextCustomizer@9da1, org.springframework.boot.test.autoconfigure.properties.Property
MappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCu
stomizerFactory$Customizer@49912c99, org.springframework.boot.test.context.SpringBootTestAnnotation@5
b3cbcb5], resourceBasePath = "src/main/webapp", contextLoader = org.springframework.boot.test.context.Spr
ingBootContextLoader, parent = null]

 

오류들이 떴다,,, @! 비상비상 ㅠㅠ 분명 강의 그대로 보고 따라 쳤는데 왜 안됐지?? 하며 오류를 읽어내려보다가,,

 

Not a managed type: class java.lang.Object

대충 뭐 위와 같은 오류를 발견했다. 고대로 긁어다가 구글링 해서 찾은 결과는,,, 인터페이스 상속을 잘못해서 🥺

 

 

public interface OrderRepository extends JpaRepository<Object, String> { }

무슨 제네릭 타입에 Object 타입을 넣어주고 왜 안 돌아가냐고 울고 있었다. ㅋㅋㅋㅋㅋ큐ㅠㅠㅠㅠㅠ

 

Object 타입은 Entity가 아니니까,, 안 돌아갑니다.. !!!!!!

 

 

public interface OrderRepository extends JpaRepository<Order, String> { }

Entity 객체로 바꿔주니까 잘만 돌아갔다!

 

 

 

 

 

References

https://jinseobbae.github.io/jpa/2021/12/06/jpa-repository-not-managed-type-error.html

반응형
LIST