• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

H2 DB 테이블 생성이 안됩니다.

23.12.31 15:18 작성 조회수 601

0

안녕하세요 H2 DB 테이블 생성이 안되는데, 스프링부트를 실행하면 에러도 안납니다.

  1. H2 연결되어 있습니다.

  1. 처음에 jpashop.mv.db 도 잘 생성되었습니다.

  2. 스프링부트를 실행하면 어떤 에러도 없지만, DB테이블이 만들어 지는 문구가 하나도 없습니다

  3. H2 콘솔창도 DB 테이블 한개도 없이 아주 깨끗합니다.

  4. 어떻게 해결할 수 있을까요??

 


  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.1.7)

2023-12-31T15:17:34.731+09:00  INFO 13760 --- [  restartedMain] jpabook.jpashop.JpashopApplication       : Starting JpashopApplication using Java 21.0.1 with PID 13760 (C:\Users\dqk86\Downloads\jpashop\out\production\classes started by dqk86 in C:\Users\dqk86\Downloads\jpashop)
2023-12-31T15:17:34.734+09:00  INFO 13760 --- [  restartedMain] jpabook.jpashop.JpashopApplication       : No active profile set, falling back to 1 default profile: "default"
2023-12-31T15:17:34.825+09:00  INFO 13760 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2023-12-31T15:17:34.825+09:00  INFO 13760 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2023-12-31T15:17:35.417+09:00  INFO 13760 --- [  restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2023-12-31T15:17:35.437+09:00  INFO 13760 --- [  restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 12 ms. Found 0 JPA repository interfaces.
2023-12-31T15:17:36.132+09:00  INFO 13760 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2023-12-31T15:17:36.147+09:00  INFO 13760 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2023-12-31T15:17:36.148+09:00  INFO 13760 --- [  restartedMain] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.17]
2023-12-31T15:17:36.213+09:00  INFO 13760 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2023-12-31T15:17:36.214+09:00  INFO 13760 --- [  restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1387 ms
2023-12-31T15:17:36.254+09:00  INFO 13760 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2023-12-31T15:17:36.443+09:00  INFO 13760 --- [  restartedMain] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Added connection conn0: url=jdbc:h2:mem:8b0a757c-2d15-4737-adab-1dbaee374f3e user=SA
2023-12-31T15:17:36.445+09:00  INFO 13760 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2023-12-31T15:17:36.455+09:00  INFO 13760 --- [  restartedMain] o.s.b.a.h2.H2ConsoleAutoConfiguration    : H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:8b0a757c-2d15-4737-adab-1dbaee374f3e'
2023-12-31T15:17:36.698+09:00  INFO 13760 --- [  restartedMain] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2023-12-31T15:17:36.806+09:00  INFO 13760 --- [  restartedMain] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 6.2.17.Final
2023-12-31T15:17:36.809+09:00  INFO 13760 --- [  restartedMain] org.hibernate.cfg.Environment            : HHH000406: Using bytecode reflection optimizer
2023-12-31T15:17:37.052+09:00  INFO 13760 --- [  restartedMain] o.s.o.j.p.SpringPersistenceUnitInfo      : No LoadTimeWeaver setup: ignoring JPA class transformer
2023-12-31T15:17:37.941+09:00  INFO 13760 --- [  restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000489: No JTA platform available (set 'hibernate.transaction.jta.platform' to enable JTA platform integration)
2023-12-31T15:17:37.984+09:00  INFO 13760 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2023-12-31T15:17:38.027+09:00  WARN 13760 --- [  restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2023-12-31T15:17:38.195+09:00  INFO 13760 --- [  restartedMain] o.s.b.a.w.s.WelcomePageHandlerMapping    : Adding welcome page: class path resource [static/index.html]
2023-12-31T15:17:38.552+09:00  INFO 13760 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2023-12-31T15:17:38.576+09:00  INFO 13760 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2023-12-31T15:17:38.587+09:00  INFO 13760 --- [  restartedMain] jpabook.jpashop.JpashopApplication       : Started JpashopApplication in 4.164 seconds (process running for 4.578)

 

답변 2

·

답변을 작성해보세요.

0

OMG님의 프로필

OMG

2023.12.31

안녕하세요. 혁짱님, 공식 서포터즈 OMG입니다.

이 경우에는 h2 DB 연결이 h2 인메모리와 매핑이 되어 있는것으로 예상이 됩니다.

image

application.yml을 강의 메뉴얼을 참고하여 작성해주세요.

띄어쓰기를 주의해주세요!

image 

감사합니다.

혁짱님의 프로필

혁짱

질문자

2023.12.31

spring:
  datasource:
    url: jdbc:h2:tcp://localhost/~/jpashop;
    username: sa
    password:
    driver-class-name: org.h2.Driver

  jpa:
    hibernate:
      ddl-auto: update
    properties:
      hibernate:
#        show_sql: true
        format_sql: true
logging:
  level:
    org.hibernate.SQL: debug

띄어쓰기 모두 라인 맞춰져있는 것 같은데 잘못된건가요?

OMG님의 프로필

OMG

2023.12.31

 

image띄어쓰기에는 문제가 없는 것 같습니다.

ddl-auto를 update가 아닌 create로 변경해서 확인해보시겠어요?

 해결이 안될 경우 댓글남겨주세요~

0

인프런 AI 인턴님의 프로필

인프런 AI 인턴

2023.12.31

안녕하세요, 인프런 AI 인턴입니다.

혁짱님의 H2 DB 테이블 생성 관련 질문에 대한 답변을 찾아드리겠습니다.

비슷한 문제를 겪고 계신 다른 학습자의 질문과 강사님의 답변이 있어 도움이 될 것 같습니다. 아래 링크를 참조하시면 해결에 도움이 될 수 있습니다.

해당 링크 내용을 확인하시고 설정을 다시 한번 점검해보시기 바랍니다.

도움이 되셨길 바랍니다. 감사합니다.

혁짱님의 프로필

혁짱

질문자

2023.12.31

네 3가지 모두 읽어보았습니다. 저는 3가지 모두에 해당되지 않는 것 같습니다.

  1. ddl-auto create로 설정되어 있습니다.

  2. yml 파일에 띄어쓰기도 잘되어있습니다.(Warning이 없습니다)

  3. entity들은 모두 하위 클래스에 있습니다. 아래 사진 첨부하겠습니다. domain package와 JapshopApplication class는 동일선상에 있습니다.

  4. 다른 해결책은 없을까요?