본문 바로가기
코드 정리/오류

Spring Boot - table 'project.diary' doesn't exist 오류

by pumkinni 2023. 3. 16.

Spring Boot - table 'project.diary' doesn't exist 오류


domain 패키지에 Diary 클래스(entity)를 생성 후 repository를 통해 save를 하는 도중

table 'project.diary' doesn't exist

오류가 발생했다.

 

entity를 생성하였는데 왜 오류가 났을까?

 

시도 1(실패)

@Entity(name="diary")

엔티티에 네임 설정하기

 

시도 2(실패)

private 뒤에 final을 추가하였다.

private final DiaryRepository diaryRepository;

 

시도3(성공)

application.properties 파일에 아래 코드 추가

spring.jpa.generate-ddl=true

 


참고

https://stackoverflow.com/questions/19140163/auto-creating-tables-failed-in-spring-jpa

 

Auto creating tables failed in Spring JPA

I have an issue with Spring JPA, Hibernate, MySQL. I have an Entity (Nom.java) and repository (public interface NomRepository extends JpaRepository<Nom, String>). They are created and injecte...

stackoverflow.com