• 카테고리

    질문 & 답변
  • 세부 분야

    풀스택

  • 해결 여부

    미해결

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

24.01.17 12:20 작성 24.01.17 12:23 수정 조회수 715

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


여기에 있으면 될것 같아요

0

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

에러가 났다면 대부분 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님의 프로필

nwj1016

2024.01.17

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 는 기존과 동일합니다.

 

 

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

 

 

 

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

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

 

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

채널톡 아이콘