작성
·
3.1K
0
예전에 jpa 활용을 듣고 진행했을 때는 실행 시 h2에 엔티티들이 잘 들어갔고 그 때 작성했던 jpashop은 여전히 잘 동작하는데 이번에 다시 새로운 프로젝트를 만들고 똑같은 설정으로 다시 하는데 h2에 테이블이 자동생성되지 않습니다 이유를 잘 모르겠습니다ㅠㅠ
전에 했던 다른 프로젝트로 db 파일에 접근하는건 잘 되는데 이 프로젝트에서만 안되는걸보니 이 프로젝트에서 뭔가 잘못된게 있는것 같습니다
application.yml
spring:
datasource:
url: jdbc:h2:tcp://localhost/~/sss
username: sa
password:
driver-class-name: org.h2.Driver
jpa:
hibernate:
ddl-auto: create
properties:
hibernate:
format_sql: true
logging.level:
org.hibernate.SQL: debug
Member 엔티티
package com.sss.domain;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@Entity
@Data
public class Member {
@Id @GeneratedValue
@Column(name = "member_id")
private Long id;
private String name;
}
"C:\Program Files\Java\jdk-11.0.11\bin\java.exe" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2021.1.3\lib\idea_rt.jar=52190:C:\Program Files\JetBrains\IntelliJ IDEA 2021.1.3\bin" -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -Dfile.encoding=UTF-8 -classpath C:\springProjects\subscriptionsharing\out\production\classes;C:\springProjects\subscriptionsharing\out\production\resources;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.projectlombok\lombok\1.18.22\9c08ea24c6eb714e2d6170e8122c069a0ba9aacf\lombok-1.18.22.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-data-jpa\2.5.6\8d7fe99c33e09390316749614d9795d80b49207b\spring-boot-starter-data-jpa-2.5.6.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-validation\2.5.6\89f34956247743c97e16fa0dd7176743fc8dea08\spring-boot-starter-validation-2.5.6.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-web\2.5.6\46b479490170914f7477b96a21241183b181c24d\spring-boot-starter-web-2.5.6.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-aop\2.5.6\c5db1260ecf447f55419f1a17da75a42f211aca3\spring-boot-starter-aop-2.5.6.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-jdbc\2.5.6\cf01e787378c2d30b695f0c9f76fb48a6b490984\spring-boot-starter-jdbc-2.5.6.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\jakarta.transaction\jakarta.transaction-api\1.3.3\c4179d48720a1e87202115fbed6089bdc4195405\jakarta.transaction-api-1.3.3.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\jakarta.persistence\jakarta.persistence-api\2.2.3\8f6ea5daedc614f07a3654a455660145286f024e\jakarta.persistence-api-2.2.3.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.hibernate\hibernate-core\5.4.32.Final\99a5e10bf455337014c190e141ec631e9ff71663\hibernate-core-5.4.32.Final.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.springframework.data\spring-data-jpa\2.5.6\8e0ec2f54f3fcda49dfb3123f3a40f34b55df92a\spring-data-jpa-2.5.6.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.springframework\spring-aspects\5.3.12\3cccc3052c6973c059eb2be7c4baf0b9558d49b7\spring-aspects-5.3.12.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter\2.5.6\d5d1fada1afe9a808abf48da7066a993cf679aa\spring-boot-starter-2.5.6.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-el\9.0.54\9edb062d38d0fd8a165289f44b28b3b0e0e11ed7\tomcat-embed-el-9.0.54.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.hibernate.validator\hibernate-validator\6.2.0.Final\d6b0760dfffbf379cedd02f715ff4c9a2e215921\hibernate-validator-6.2.0.Final.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-json\2.5.6\6ef5a7087e18ed4f3736c8752440ecd489c36a4d\spring-boot-starter-json-2.5.6.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-tomcat\2.5.6\6d1a04a727d9d09b99207864ceb0a4567e53730a\spring-boot-starter-tomcat-2.5.6.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.springframework\spring-webmvc\5.3.12\3d92ad6c28bfa5923183f328f5bfa1e39ec32714\spring-webmvc-5.3.12.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.springframework\spring-web\5.3.12\78991a50d17da49bddc4987a2cc8b83d46c402a7\spring-web-5.3.12.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.springframework\spring-aop\5.3.12\882db41939109e96f4c78cd5c0931cc4aebc3d58\spring-aop-5.3.12.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.aspectj\aspectjweaver\1.9.7\158f5c255cd3e4408e795b79f7c3fbae9b53b7ca\aspectjweaver-1.9.7.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\com.zaxxer\HikariCP\4.0.3\107cbdf0db6780a065f895ae9d8fbf3bb0e1c21f\HikariCP-4.0.3.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.springframework\spring-jdbc\5.3.12\957d6ddc80fbf52d965e6af90ddd0dccfed42d7d\spring-jdbc-5.3.12.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.hibernate.common\hibernate-commons-annotations\5.1.2.Final\e59ffdbc6ad09eeb33507b39ffcf287679a498c8\hibernate-commons-annotations-5.1.2.Final.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.jboss.logging\jboss-logging\3.4.2.Final\e517b8a93dd9962ed5481345e4d262fdd47c4217\jboss-logging-3.4.2.Final.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.javassist\javassist\3.27.0-GA\f63e6aa899e15eca8fdaa402a79af4c417252213\javassist-3.27.0-GA.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\net.bytebuddy\byte-buddy\1.10.22\ef45d7e2cd1c600d279704f492ed5ce2ceb6cdb5\byte-buddy-1.10.22.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\antlr\antlr\2.7.7\83cd2cd674a217ade95a4bb83a8a14f351f48bd0\antlr-2.7.7.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.jboss\jandex\2.2.3.Final\d3865101f0666b63586683bd811d754517f331ab\jandex-2.2.3.Final.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\com.fasterxml\classmate\1.5.1\3fe0bed568c62df5e89f4f174c101eab25345b6c\classmate-1.5.1.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.dom4j\dom4j\2.1.3\a75914155a9f5808963170ec20653668a2ffd2fd\dom4j-2.1.3.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.glassfish.jaxb\jaxb-runtime\2.3.5\a169a961a2bb9ac69517ec1005e451becf5cdfab\jaxb-runtime-2.3.5.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.springframework\spring-context\5.3.12\d5f5f044e05109b7f3337ea2cf692fd62d1ecbb6\spring-context-5.3.12.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.springframework\spring-orm\5.3.12\2881f9e71889b35fa3785bf67706a201cea93004\spring-orm-5.3.12.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.springframework.data\spring-data-commons\2.5.6\15a2384f4eaf7fee512fb295174f6c0fb6c55ee1\spring-data-commons-2.5.6.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.springframework\spring-tx\5.3.12\7f2e61a22682baa22ed5bef0724a4386c41477cb\spring-tx-5.3.12.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.springframework\spring-beans\5.3.12\caaa1d489bce88d6aa01ddd255ad5046acf8f282\spring-beans-5.3.12.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.springframework\spring-core\5.3.12\662e6536968246af9baa84fbac2d3eb56a04fda9\spring-core-5.3.12.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-api\1.7.32\cdcff33940d9f2de763bc41ea05a0be5941176c3\slf4j-api-1.7.32.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-autoconfigure\2.5.6\b9f4016180c5242530da465561ff25c7cac14bf3\spring-boot-autoconfigure-2.5.6.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot\2.5.6\d8c6b97fd3182fb6d7d06ebf710cd9ccabc83b89\spring-boot-2.5.6.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-logging\2.5.6\a900356a11b1a41f4277136f1d13ce7a13f43b3c\spring-boot-starter-logging-2.5.6.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\jakarta.annotation\jakarta.annotation-api\1.3.5\59eb84ee0d616332ff44aba065f3888cf002cd2d\jakarta.annotation-api-1.3.5.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.yaml\snakeyaml\1.28\7cae037c3014350c923776548e71c9feb7a69259\snakeyaml-1.28.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\jakarta.validation\jakarta.validation-api\2.0.2\5eacc6522521f7eacb081f95cee1e231648461e7\jakarta.validation-api-2.0.2.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jsr310\2.12.5\a0a9870b681a72789c5c6bdc380e45ab719c6aa3\jackson-datatype-jsr310-2.12.5.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.module\jackson-module-parameter-names\2.12.5\2c85c2036d0851425a260c01eb5f7ddbed1eeb00\jackson-module-parameter-names-2.12.5.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jdk8\2.12.5\6b2f79547d217ad50dfc5b57af7444a3aa583b43\jackson-datatype-jdk8-2.12.5.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.12.5\b064cf057f23d3d35390328c5030847efeffedde\jackson-databind-2.12.5.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-websocket\9.0.54\ae018906cecb818a8c6f2316d7b0793beadf6609\tomcat-embed-websocket-9.0.54.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-core\9.0.54\34322c731b2394ea13681cfae0be9cd72f46f88d\tomcat-embed-core-9.0.54.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.springframework\spring-expression\5.3.12\50c82e995b3b8e20a3f313b4356237db5a26e14a\spring-expression-5.3.12.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\jakarta.xml.bind\jakarta.xml.bind-api\2.3.3\48e3b9cfc10752fba3521d6511f4165bea951801\jakarta.xml.bind-api-2.3.3.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.glassfish.jaxb\txw2\2.3.5\ec8930fa62e7b1758b1664d135f50c7abe86a4a3\txw2-2.3.5.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\com.sun.istack\istack-commons-runtime\3.0.12\cbbe1a62b0cc6c85972e99d52aaee350153dc530\istack-commons-runtime-3.0.12.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.springframework\spring-jcl\5.3.12\2b5f5bb4a78af879bd174ceff5226da3f014ab9d\spring-jcl-5.3.12.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\ch.qos.logback\logback-classic\1.2.6\b09efa852337fa0dd9859614389eec58dc287116\logback-classic-1.2.6.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-to-slf4j\2.14.1\ce8a86a3f50a4304749828ce68e7478cafbc8039\log4j-to-slf4j-2.14.1.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.slf4j\jul-to-slf4j\1.7.32\8a055c04ab44e8e8326901cadf89080721348bdb\jul-to-slf4j-1.7.32.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.12.5\52d929d5bb21d0186fe24c09624cc3ee4bafc3b3\jackson-annotations-2.12.5.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.12.5\725e364cc71b80e60fa450bd06d75cdea7fb2d59\jackson-core-2.12.5.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\ch.qos.logback\logback-core\1.2.6\25be1abb32e870ff042e698a799b56587e0dca9a\logback-core-1.2.6.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-api\2.14.1\cd8858fbbde69f46bce8db1152c18a43328aae78\log4j-api-2.14.1.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\com.h2database\h2\1.4.200\f7533fe7cb8e99c87a43d325a77b4b678ad9031a\h2-1.4.200.jar;C:\Users\NOTE\.gradle\caches\modules-2\files-2.1\com.sun.activation\jakarta.activation\1.2.2\74548703f9851017ce2f556066659438019e7eb5\jakarta.activation-1.2.2.jar com.sss.subscriptionsharing.SubscriptionsharingApplication
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.5.6)
2021-11-12 19:52:53.930 INFO 13244 --- [ main] c.s.s.SubscriptionsharingApplication : Starting SubscriptionsharingApplication using Java 11.0.11 on DESKTOP-N9VOSQK with PID 13244 (C:\springProjects\subscriptionsharing\out\production\classes started by NOTE in C:\springProjects\subscriptionsharing)
2021-11-12 19:52:53.933 INFO 13244 --- [ main] c.s.s.SubscriptionsharingApplication : No active profile set, falling back to default profiles: default
2021-11-12 19:52:54.540 INFO 13244 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-11-12 19:52:54.551 INFO 13244 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 5 ms. Found 0 JPA repository interfaces.
2021-11-12 19:52:54.968 INFO 13244 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2021-11-12 19:52:54.977 INFO 13244 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-11-12 19:52:54.977 INFO 13244 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.54]
2021-11-12 19:52:55.083 INFO 13244 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-11-12 19:52:55.083 INFO 13244 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1109 ms
2021-11-12 19:52:55.184 INFO 13244 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-11-12 19:52:55.223 INFO 13244 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.32.Final
2021-11-12 19:52:55.326 INFO 13244 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-11-12 19:52:55.406 INFO 13244 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-11-12 19:52:55.445 INFO 13244 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-11-12 19:52:55.461 INFO 13244 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2021-11-12 19:52:55.626 INFO 13244 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-11-12 19:52:55.635 INFO 13244 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-11-12 19:52:55.674 WARN 13244 --- [ 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
2021-11-12 19:52:55.929 INFO 13244 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2021-11-12 19:52:55.938 INFO 13244 --- [ main] c.s.s.SubscriptionsharingApplication : Started SubscriptionsharingApplication in 2.627 seconds (JVM running for 4.267)
답변 1
0
안녕하세요. 이동규님, 공식 서포터즈 OMG입니다.
테이블 생성이 안되는 이유가 몇가지 존재하는데요,
1. application.yml의 위치 문제
2. application.yml 내에서 오타 혹은 띄어쓰기 문제
3. 엔티티 클래스 위치
1) application.yml의 위치를 다시 확인해보시겠어요?
src/main/resources
2) 1)의 위치에 yml파일이 존재한다면 아래의 내용을 복사 붙여넣기 해보시겠어요?
spring:
datasource:
url: jdbc:h2:tcp://localhost/~/sss
username: sa
password:
driver-class-name: org.h2.Driver
jpa:
hibernate:
ddl-auto: create
properties:
hibernate:
#show_sql: true
format_sql: true
logging:
level:
org.hibernate.SQL: debug
3) 패키지의 구조를 강의와 동일하게 하셨을까요? 아닌 경우 강의와 동일하게 진행해주세요
https://www.inflearn.com/questions/98947
해결이 안될 경우 댓글 남겨주세요
감사합니다.
패키지 구조 문제였네요ㅠㅠ 감사합니다!!! 해결했습니다