[Springboot]yml 오류

Train·2022년 11월 28일
0
post-thumbnail

김영한 JPA 학습 중에 test 작동 중 겉으로 오류가 없음에도 아래와 같은 코드가 작동하면서 H2 데이터베이스에 테이블이 추가가 안되었다.

20:01:42.349 [main] DEBUG org.springframework.test.context.junit4.SpringJUnit4ClassRunner - SpringJUnit4ClassRunner constructor called with [class com.jpabook.jpashop.MemberRepositoryTest]
20:01:42.387 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
20:01:42.414 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
20:01:42.525 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.jpabook.jpashop.MemberRepositoryTest] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
20:01:42.560 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.jpabook.jpashop.MemberRepositoryTest], using SpringBootContextLoader
20:01:42.574 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.jpabook.jpashop.MemberRepositoryTest]: class path resource [com/jpabook/jpashop/MemberRepositoryTest-context.xml] does not exist
20:01:42.576 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.jpabook.jpashop.MemberRepositoryTest]: class path resource [com/jpabook/jpashop/MemberRepositoryTestContext.groovy] does not exist
20:01:42.576 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.jpabook.jpashop.MemberRepositoryTest]: no resource found for suffixes {-context.xml, Context.groovy}.
20:01:42.578 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.jpabook.jpashop.MemberRepositoryTest]: MemberRepositoryTest does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
20:01:42.763 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [com.jpabook.jpashop.MemberRepositoryTest]
20:01:43.020 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [C:\GDJ\JPA\jpashop\build\classes\java\main\com\jpabook\jpashop\JpashopApplication.class]
20:01:43.031 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration com.jpabook.jpashop.JpashopApplication for test class com.jpabook.jpashop.MemberRepositoryTest
20:01:43.445 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [com.jpabook.jpashop.MemberRepositoryTest]: using defaults.
20:01:43.447 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.event.ApplicationEventsTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener]
20:01:43.514 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@2a225dd7, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@61eaec38, org.springframework.test.context.event.ApplicationEventsTestExecutionListener@125290e5, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@6fa34d52, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@57576994, org.springframework.test.context.support.DirtiesContextTestExecutionListener@616ac46a, org.springframework.test.context.transaction.TransactionalTestExecutionListener@67b9b51a, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@1205bd62, org.springframework.test.context.event.EventPublishingTestExecutionListener@7ef27d7f, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@490caf5f, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@6337c201, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@5c669da8, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@31920ade, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener@1d483de4, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@4032d386]
20:01:43.521 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.jpabook.jpashop.MemberRepositoryTest]
20:01:43.524 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.jpabook.jpashop.MemberRepositoryTest]
20:01:43.529 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.jpabook.jpashop.MemberRepositoryTest]
20:01:43.530 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.jpabook.jpashop.MemberRepositoryTest]
20:01:43.530 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.jpabook.jpashop.MemberRepositoryTest]
20:01:43.530 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.jpabook.jpashop.MemberRepositoryTest]
20:01:43.555 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.jpabook.jpashop.MemberRepositoryTest]
20:01:43.555 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.jpabook.jpashop.MemberRepositoryTest]
20:01:43.558 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.jpabook.jpashop.MemberRepositoryTest]
20:01:43.559 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.jpabook.jpashop.MemberRepositoryTest]
20:01:43.560 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.jpabook.jpashop.MemberRepositoryTest]
20:01:43.561 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.jpabook.jpashop.MemberRepositoryTest]
20:01:43.577 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@4196c360 testClass = MemberRepositoryTest, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@41294f8 testClass = MemberRepositoryTest, locations = '{}', classes = '{class com.jpabook.jpashop.JpashopApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@2aceadd4, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@2002fc1d, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@7dc0f706, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@2de23121, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@45b4c3a9, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@8dbdac1], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true]], class annotated with @DirtiesContext [false] with mode [null].
20:01:43.584 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.jpabook.jpashop.MemberRepositoryTest]
20:01:43.584 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.jpabook.jpashop.MemberRepositoryTest]

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

2022-11-28 20:01:44.991  INFO 17556 --- [           main] c.jpabook.jpashop.MemberRepositoryTest   : Starting MemberRepositoryTest using Java 11.0.15 on DESKTOP-6OCVCGB with PID 17556 (started by minhwan2 in C:\GDJ\JPA\jpashop)
2022-11-28 20:01:44.995  INFO 17556 --- [           main] c.jpabook.jpashop.MemberRepositoryTest   : No active profile set, falling back to 1 default profile: "default"
2022-11-28 20:01:47.607  INFO 17556 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-11-28 20:01:47.661  INFO 17556 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 22 ms. Found 0 JPA repository interfaces.
2022-11-28 20:01:52.614  INFO 17556 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2022-11-28 20:01:53.675  INFO 17556 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2022-11-28 20:01:53.887  INFO 17556 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2022-11-28 20:01:54.071  INFO 17556 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.6.14.Final
2022-11-28 20:01:54.616  INFO 17556 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2022-11-28 20:01:55.121  INFO 17556 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2022-11-28 20:01:57.087 DEBUG 17556 --- [           main] org.hibernate.SQL                        : drop table if exists member CASCADE 
2022-11-28 20:01:57.095 DEBUG 17556 --- [           main] org.hibernate.SQL                        : drop sequence if exists hibernate_sequence
2022-11-28 20:01:57.099 DEBUG 17556 --- [           main] org.hibernate.SQL                        : create sequence hibernate_sequence start with 1 increment by 1
2022-11-28 20:01:57.104 DEBUG 17556 --- [           main] org.hibernate.SQL                        : create table member (id bigint not null, username varchar(255), primary key (id))
2022-11-28 20:01:57.119  INFO 17556 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2022-11-28 20:01:57.141  INFO 17556 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2022-11-28 20:01:58.135  WARN 17556 --- [           main] 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
2022-11-28 20:02:00.176  INFO 17556 --- [           main] c.jpabook.jpashop.MemberRepositoryTest   : Started MemberRepositoryTest in 16.473 seconds (JVM running for 19.907)
2022-11-28 20:02:00.577  INFO 17556 --- [           main] o.s.t.c.transaction.TransactionContext   : Began transaction (1) for test context [DefaultTestContext@4196c360 testClass = MemberRepositoryTest, testInstance = com.jpabook.jpashop.MemberRepositoryTest@129aaac1, testMethod = testMember@MemberRepositoryTest, testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@41294f8 testClass = MemberRepositoryTest, locations = '{}', classes = '{class com.jpabook.jpashop.JpashopApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@2aceadd4, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@2002fc1d, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@7dc0f706, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@2de23121, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@45b4c3a9, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@8dbdac1], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true, 'org.springframework.test.context.web.ServletTestExecutionListener.populatedRequestContextHolder' -> true, 'org.springframework.test.context.web.ServletTestExecutionListener.resetRequestContextHolder' -> true, 'org.springframework.test.context.event.ApplicationEventsTestExecutionListener.recordApplicationEvents' -> false]]; transaction manager [org.springframework.orm.jpa.JpaTransactionManager@67671db1]; rollback [true]
2022-11-28 20:02:01.007 DEBUG 17556 --- [           main] org.hibernate.SQL                        : call next value for hibernate_sequence
2022-11-28 20:02:01.255  INFO 17556 --- [           main] o.s.t.c.transaction.TransactionContext   : Rolled back transaction for test: [DefaultTestContext@4196c360 testClass = MemberRepositoryTest, testInstance = com.jpabook.jpashop.MemberRepositoryTest@129aaac1, testMethod = testMember@MemberRepositoryTest, testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@41294f8 testClass = MemberRepositoryTest, locations = '{}', classes = '{class com.jpabook.jpashop.JpashopApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@2aceadd4, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@2002fc1d, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@7dc0f706, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@2de23121, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@45b4c3a9, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@8dbdac1], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true, 'org.springframework.test.context.web.ServletTestExecutionListener.populatedRequestContextHolder' -> true, 'org.springframework.test.context.web.ServletTestExecutionListener.resetRequestContextHolder' -> true, 'org.springframework.test.context.event.ApplicationEventsTestExecutionListener.recordApplicationEvents' -> false]]
2022-11-28 20:02:01.273  INFO 17556 --- [ionShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2022-11-28 20:02:01.273  INFO 17556 --- [ionShutdownHook] .SchemaDropperImpl$DelayedDropActionImpl : HHH000477: Starting delayed evictData of schema as part of SessionFactory shut-down'
2022-11-28 20:02:01.275 DEBUG 17556 --- [ionShutdownHook] org.hibernate.SQL                        : drop table if exists member CASCADE 
2022-11-28 20:02:01.278 DEBUG 17556 --- [ionShutdownHook] org.hibernate.SQL                        : drop sequence if exists hibernate_sequence
2022-11-28 20:02:01.281  INFO 17556 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2022-11-28 20:02:01.291  INFO 17556 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.

Process finished with exit code 0

구글링을 통해 많은 시간을 소비한 결과, 내가 yml 설정 파일을 처음이용해서 생긴 기초적인 오류임을 알게 되었다.
기존 설정 파일처럼 띄어쓰기 무시를 했었는데 상위 설정 밑 하위 설정이 따로 있어 띄어쓰기를 무시하면서 h2설정이 작동이 안되어 오류가 발생한 것이다.

아래처럼 설정하니 다시 잘 작동하였다.

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

  jpa:
    hibernate:
      ddl-auto: create
    properties:
      hibernate:
        #  show_sql: true   #sql 보기
        format_sql: true

logging.level:
  org.hibernate.SQL: debug #로거로 보기

server:
  port: 8082
profile
성장하고 싶은 0년차 개발자

0개의 댓글