[ UnsatisfiedDependencyException : Not a managed type ]
org.springframework.beans.factory.UnsatisfiedDependencyException
: Error creating bean with name 'personController' . . . 'personService' . . . 'personRepository' . . .
. . .nested exception is java.lang.IllegalArgumentException: Not a managed type
스프링으로 간단한 예제를 학습하던 도중
이런 에러를 보게 되었다.
UnsatisfiedDependenctException을 일으키는 원인은 다양하게 있지만,
구글링 및 코드를 하나하나 본 결과
Person class에 문제가 있었다. ( Entity 역할 )
@Getter
@NoArgsConstructor
public class Person {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "person_id")
private Long id;
private String name;
private int age;
private String address;
private String job;
public Person(PersonInfoDto personInfoDto){
this.name = personInfoDto.getName();
this.age = personInfoDto.getAge();
this.address = personInfoDto.getAddress();
this.job = personInfoDto.getJob();
}
// Update Query 에 쓰일 Entity
public Person(Long id, PersonInfoDto personInfoDto){
this.id = id;
this.name = personInfoDto.getName();
this.age = personInfoDto.getAge();
this.address = personInfoDto.getAddress();
this.job = personInfoDto.getJob();
}
// Update Query 에 쓰일 Method2
public void editPerson(PersonInfoDto personInfoDto){
this.name = personInfoDto.getName();
this.age = personInfoDto.getAge();
this.address = personInfoDto.getAddress();
this.job = personInfoDto.getJob();
}
}
엔티티 Person에 의존하는
PersonController, PersonService, PersonRepository의 Bean 생성 시,
Person class에 @Entity 어노테이션을 붙여주지 않았기에 발생한 에러였다.
관련 자료는 아래 남겨두겠다.
https://wakestand.tistory.com/742
Not a managed type: class Entity명 해결방법
Not a managed type: class 경로.Entity명 JPA를 사용하던 도중 위와 같은 에러가 발생하던데 원인을 확인해 보니 에러가 뜬 Entity에 @Entity를 추가하지 않아 에러가 발생한 거였더라 위 이미지와 같이 @Entity
wakestand.tistory.com
[ Web server failed to start. Port 8080 was already in use. ]
8080번 포트를 기본적으로 사용하는데,
프로세스 중 다른 프로세스가 8080번 포트를 이미 사용하고 있을 때
이 오류가 발생한다.
해결방법은
1. application.properties에서 server.port = 8000과 같이, 8080번이 아닌 다른 포트를 사용하게 설정하는 방법
[ application.properties ]
server.port=8000
2. terminal을 사용해서, 8080번 포트를 사용중인 프로세스를 중지시키는 것.
1) sudo lsof -i :[확인하고싶은포트번호]' 입력하여 실행중인 포트를 확인
2) 'sudo kill -9 [실행중인포트의PID]' 를 입력하여 실행중인 포트를 중지
[스프링부트에러] - "Web server failed to start. Port 8080 was aleady in use" : 스프링부트프로젝트 실행시 포
스프링부트 프로젝트를 생성해서 실행하는데 포트에러발생시 포트를 여러번 변경을 해줘도 에러가 발생할 경우 참고해주세용 아 저는 맥북유저입니다 ! [에러내용] 스프링부트 프로젝트 생성
zincod.tistory.com
'TIL' 카테고리의 다른 글
[ 23/2/2 TIL : SQL - SELECT * FROM Table ~ Group by / Order by : 통계적인 값들 구해보기 ] (0) | 2023.02.02 |
---|---|
[ 23/2/1 TIL - SQL 기본 : SELECT 문 - WHERE / BETWEEN / IN / AND / OR | 크롬 개발자 도구 console 창 글자 크기 키우기 | Java class & interface : extends vs implements ] (0) | 2023.02.01 |
[ 1/25 ] 구조해조 KPT 회고 (0) | 2023.01.26 |
[ 23년 1월 9일 Today I Learned ] 자바 기본 문법 & 클래스 복습 (0) | 2023.01.10 |
[ 11/29 일잘하조 KPT 회고 ] (1) | 2022.11.29 |