인프런 커뮤니티 질문&답변

작성자 없음

작성자 정보가 삭제된 글입니다.

코드로 배우는 React with 스프링부트 API서버

부트 프로젝트 생성 및 확인

테이블이 생성되지 않습니다

24.01.17 12:20 작성

·

1K

·

수정됨

0

spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.datasource.url=jdbc:mariadb://localhost:3306/malldb
spring.datasource.username=malldbuser
spring.datasource.password=malldbuser

spring.jpa.hibernate.ddl
-auto = update
spring.jpa.prop
erties.hibernate.format_sql = true

 

 

@Entity
@ToString
@Getter
@Builder    // Builder 를 사용하게 되면 아래 2개의 어노테이션도 함께 사용해야함
@AllArgsConstructor
@NoArgsConstructor
public class ToDo {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String title;
    private String content;
    private boolean complete;
    private LocalDate dueDate;


}

 

위처럼 properties 를 작성했는데 ToDo 테이블이 생성되지 않습니다...오류는 전혀 뜨지 않고 있습니다...무엇이 문제인지 잘 모르겠습니다

답변 2

0

김태우님의 프로필 이미지

2024. 01. 25. 22:07


여기에 있으면 될것 같아요

0

구멍가게코딩단님의 프로필 이미지
구멍가게코딩단
지식공유자

2024. 01. 17. 12:34

우선은 현재 상황에서 프로젝트 시작시에 에러가 안 나는지 확인해 주세요..

에러가 났다면 대부분 DB 연결이 안되서 그럴 것입니다.

 

테이블 생성과 관련해서는 application.properties 파일에

 

spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.show-sql=true

설정이 필요합니다. ddl-auto 값이 update로 되어 있으면 테이블이 생성됩니다.

 

 

nwj1016님의 프로필 이미지

2024. 01. 17. 12:36

spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.datasource.url=jdbc:mariadb://localhost:3306/malldb
spring.datasource.username=malldbuser
spring.datasource.password=malldbuser

spring.jpa.hibernate.ddl
-auto = update
spring.jp
a.show-sql=true
spring.jpa.pro
perties.hibernate.format_sql = true

 

이렇게 properties 작성했고, Entity 는 기존과 동일합니다.

 

 

에러는 발생하지 않습니다.....

 

 

 

구멍가게코딩단님의 프로필 이미지
구멍가게코딩단
지식공유자

2024. 01. 17. 14:54

혹시 엔티티 클래스의 패키지의 위치가 다른게 아닐까 싶은데요..

프로젝트 초기 생성시에 만들어진 패키지 아래쪽에 있어야만 인식이 됩니다.

 

해결이 안되시면 cafe.naver.com/gugucoding으로 프로젝트 파일을 압축해서 올려주세요

작성자 없음

작성자 정보가 삭제된 글입니다.

질문하기