스프링 부트 애플리케이션이 시작된 후 몇 가지 테스트 데이터를 삽입하려고합니다. 나는 아래의 구성을 가지고있다. JPA 엔티티가 작성되기 전에 SQL 스크립트가 실행되어 삽입 문이 실패 함을 알 수 있습니다. 여기에 누락 된 다른 구성이 있습니까? 내 구성에서 언급했듯이 JPA 용 H2 및 EclipseLink와 함께 Spring Boot를 사용하고 있습니다.스프링 부트 데이터 초기화
참조 https://docs.spring.io/spring-boot/docs/current/reference/html/howto-database-initialization.html
구성
data.sql이/SRC/메인/자원 아래에 배치됩니다# H2
spring.h2.console.enabled=true
# Datasource
spring.datasource.url=jdbc:h2:mem:testdb;MODE=ORACLE
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver
# JPA
spring.jpa.generate-ddl=true
spring.jpa.show-sql=true
spring.jpa.properties.eclipselink.weaving=false
로그
2017-09-05 20:37:37,989 [restartedMain ] INFO
o.s.j.d.e.EmbeddedDatabaseFactory - Starting embedded database:
url='jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=false',
username='sa'
2017-09-05 20:37:38,141 [restartedMain ] INFO
j.LocalContainerEntityManagerFactoryBean - Building JPA container
EntityManagerFactory for persistence unit 'default'
2017-09-05 20:37:38,446 [restartedMain ] INFO
o.s.o.j.AbstractEntityManagerFactoryBean - Initialized JPA
EntityManagerFactory for persistence unit 'default'
2017-09-05 20:37:38,510 [restartedMain ] INFO o.s.j.d.i.ScriptUtils
- Executing SQL script from URL [file:/develop/src/data-init/target/classes/data.sql]
error...
법인
@Entity
@Table(name = "TEMPLATE_CONFIG")
@Data
public class TemplateUser {
@Id
@Column(name = "TEMPLATE_CONFIG_ID", nullable = false)
private Long configId;
@Column(name = "APP_CODE", nullable = false, length = 100)
private String appCode;
...
}
업데이트
업로드 샘플 프로젝트 : https://git.io/v5SWx
엔티티의 모양을 게시 할 수 있습니까? @Entity annotation이 붙어 있어야합니다. –
엔티티가 추가되었습니다. – Srini
'spring.jpa.hibernate.ddl-auto : create' 속성도 설정해 보았습니까? https://docs.spring.io/spring-boot/docs/current/reference/html/howto-database-initialization.html#howto-initialize-a-database-using-jpa –