강의

멘토링

로드맵

Inflearn brand logo image

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

nickheatlhy님의 프로필 이미지
nickheatlhy

작성한 질문수

실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발

JPA와 DB 설정, 동작확인

데이터베이스 테이블 생성 안됨

작성

·

76

0

로그는 잘 나가는 것 같은데 데이터베이스를 확인해보면 테이블이랑 데이터가 안 들어가는 것 같습니다 ㅠ

 

그리고 ddl-auto 모드도 none 으로 바꿔봐도 계속 같은 로그가 나옵니다.(테이블 생성 및 drop)

 

로그 첨부할게요.

> Task :compileJava UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :compileTestJava UP-TO-DATE
> Task :processTestResources UP-TO-DATE
> Task :testClasses UP-TO-DATE
19:41:14.516 [Test worker] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils -- Could not detect default configuration classes for test class [jpabook.jpashop.MemberRepositoryTest]: MemberRepositoryTest does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
19:41:14.568 [Test worker] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper -- Found @SpringBootConfiguration jpabook.jpashop.JpashopApplication for test class jpabook.jpashop.MemberRepositoryTest
19:41:14.668 [Test worker] INFO org.springframework.boot.devtools.restart.RestartApplicationListener -- Restart disabled due to context in which it is running

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/

 :: Spring Boot ::                (v3.4.0)

2025-06-16T19:41:14.814+09:00  INFO 56122 --- [    Test worker] jpabook.jpashop.MemberRepositoryTest     : Starting MemberRepositoryTest using Java 20.0.1 with PID 56122 (started by sungwoo in /Users/sungwoo/Documents/dev/study/online-lecture/inflearn/jpa/2.jpa-application)
2025-06-16T19:41:14.815+09:00  INFO 56122 --- [    Test worker] jpabook.jpashop.MemberRepositoryTest     : No active profile set, falling back to 1 default profile: "default"
2025-06-16T19:41:15.139+09:00  INFO 56122 --- [    Test worker] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2025-06-16T19:41:15.150+09:00  INFO 56122 --- [    Test worker] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 6 ms. Found 0 JPA repository interfaces.
2025-06-16T19:41:15.337+09:00  INFO 56122 --- [    Test worker] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2025-06-16T19:41:15.435+09:00  INFO 56122 --- [    Test worker] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Added connection conn0: url=jdbc:h2:mem:cb23765c-56b9-40bc-ba72-8f1435f049ba user=SA
2025-06-16T19:41:15.436+09:00  INFO 56122 --- [    Test worker] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2025-06-16T19:41:15.470+09:00  INFO 56122 --- [    Test worker] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2025-06-16T19:41:15.500+09:00  INFO 56122 --- [    Test worker] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 6.6.2.Final
2025-06-16T19:41:15.517+09:00  INFO 56122 --- [    Test worker] o.h.c.internal.RegionFactoryInitiator    : HHH000026: Second-level cache disabled
2025-06-16T19:41:15.661+09:00  INFO 56122 --- [    Test worker] o.s.o.j.p.SpringPersistenceUnitInfo      : No LoadTimeWeaver setup: ignoring JPA class transformer
2025-06-16T19:41:15.706+09:00  INFO 56122 --- [    Test worker] org.hibernate.orm.connections.pooling    : HHH10001005: Database info:
	Database JDBC URL [Connecting through datasource 'HikariDataSource (HikariPool-1)']
	Database driver: undefined/unknown
	Database version: 2.3.232
	Autocommit mode: undefined/unknown
	Isolation level: undefined/unknown
	Minimum pool size: undefined/unknown
	Maximum pool size: undefined/unknown
2025-06-16T19:41:16.066+09:00 DEBUG 56122 --- [    Test worker] org.hibernate.SQL                        : create global temporary table HTE_member(rn_ integer not null, id bigint, username varchar(255), primary key (rn_)) TRANSACTIONAL
2025-06-16T19:41:16.126+09:00  INFO 56122 --- [    Test worker] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000489: No JTA platform available (set 'hibernate.transaction.jta.platform' to enable JTA platform integration)
2025-06-16T19:41:16.132+09:00 DEBUG 56122 --- [    Test worker] org.hibernate.SQL                        : drop table if exists member cascade 
2025-06-16T19:41:16.133+09:00 DEBUG 56122 --- [    Test worker] org.hibernate.SQL                        : drop sequence if exists member_seq
2025-06-16T19:41:16.135+09:00 DEBUG 56122 --- [    Test worker] org.hibernate.SQL                        : create sequence member_seq start with 1 increment by 50
2025-06-16T19:41:16.137+09:00 DEBUG 56122 --- [    Test worker] org.hibernate.SQL                        : create table member (id bigint not null, username varchar(255), primary key (id))
2025-06-16T19:41:16.140+09:00  INFO 56122 --- [    Test worker] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2025-06-16T19:41:16.239+09:00  WARN 56122 --- [    Test worker] 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
2025-06-16T19:41:16.368+09:00  WARN 56122 --- [    Test worker] ion$DefaultTemplateResolverConfiguration : Cannot find template location: classpath:/templates/ (please add some templates, check your Thymeleaf configuration, or set spring.thymeleaf.check-template-location=false)
2025-06-16T19:41:16.431+09:00  INFO 56122 --- [    Test worker] jpabook.jpashop.MemberRepositoryTest     : Started MemberRepositoryTest in 1.764 seconds (process running for 2.307)
2025-06-16T19:41:16.749+09:00 DEBUG 56122 --- [    Test worker] org.hibernate.SQL                        : select next value for member_seq
2025-06-16T19:41:16.808+09:00 DEBUG 56122 --- [    Test worker] org.hibernate.SQL                        : insert into member (username,id) values (?,?)
Java HotSpot(TM) 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
2025-06-16T19:41:16.819+09:00  INFO 56122 --- [ionShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2025-06-16T19:41:16.819+09:00 DEBUG 56122 --- [ionShutdownHook] org.hibernate.SQL                        : drop table if exists member cascade 
2025-06-16T19:41:16.820+09:00 DEBUG 56122 --- [ionShutdownHook] org.hibernate.SQL                        : drop sequence if exists member_seq
2025-06-16T19:41:16.821+09:00  INFO 56122 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2025-06-16T19:41:16.822+09:00  INFO 56122 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
> Task :test
[Incubating] Problems report is available at: file:///Users/sungwoo/Documents/dev/study/online-lecture/inflearn/jpa/2.jpa-application/build/reports/problems/problems-report.html
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.11.1/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD SUCCESSFUL in 3s
5 actionable tasks: 1 executed, 4 up-to-date
오후 7:41:16: Execution finished ':test --tests "jpabook.jpashop.MemberRepositoryTest"'.

답변 4

0

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

스스로 잘 해결하셨습니다 :) 

강의 수강 중 강의 관련 궁금한 사항은 언제든 질문 남겨주세요^^

0

nickheatlhy님의 프로필 이미지
nickheatlhy
질문자

application-test.yml 파일이 존재했었네요..

스프링의 기본 인메모리 디비를 사용해서 그런 것 같습니다.

0

nickheatlhy님의 프로필 이미지
nickheatlhy
질문자

다른 방법 다 해보았는데 해결이 안되네요..
도와주시면 감사하겠습니다!

0

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

nickheatlhy님이 겪고 있는 문제는 주로 테스트 환경에서 데이터베이스 테이블이 생성되지 않는 것과 관련이 있습니다. 현재 로그를 보면, 변경 내용이 반영되지 않는 문제 또는 테이블 생성 후 곧바로 삭제되는 문제가 있을 수 있습니다. 아래 링크들을 참고하여 문제를 해결할 수 있을 것입니다.

  1. 테이블 생성이 안됩니다

    • application.yml의 설정에서 ddl-auto: create 설정을 올바르게 적용해야 합니다. 특히, 들여쓰기가 중요한 YAML 파일의 특성을 고려하여 파일을 확인해 보시기 바랍니다.
  2. JpashopApplication 실행 후에 테이블 작성이 되지 않음

    • JPA 관련 설정이 잘못되었을 때 나타나는 문제를 다루고 있으며, bootstrap-mode 설정을 통해 추가적인 문제를 진단할 수 있습니다.
  3. SQL 실행로그가 보이지 않습니다.

    • 로그 설정을 체크하여 SQL 실행 내용을 확인하고 문제를 진단할 수 있습니다. hibernate.show_sqllogging 설정을 점검해 보세요.

이와 같은 자료들을 통해 설정을 검토하시고, 특히 ddl-auto 설정의 위치와 값이 올바르게 설정되어 있는지, 테스트 환경이 어떻게 구성되어 있는지 확인해보세요. 이 외에도, 설정 파일의 들여쓰기 또는 불필요한 주석 처리로 인해 의도와 다르게 반영되지 않는 경우도 있어 이를 주의 깊게 살펴보세요.

저는 질문자님의 이해를 돕고자 지식공유자님의 기존 답변을 참고하여 유사한 답변 링크를 추천해드리고 있습니다. 현재 베타 기능으로 답변이 만족스럽지 않을 수 있는 점 양해 부탁드립니다. 🙏 추가적으로 궁금한 점이 있으시면, 이어서 질문해 주세요. 곧 지식공유자께서 답변해 주실 것입니다.

nickheatlhy님의 프로필 이미지
nickheatlhy

작성한 질문수

질문하기