insert 가 안됩니다...
467
작성한 질문수 1
data.sql을 만들고 insert구문을 쓰면 Table "USERALL" not found 에러가 뜹니다

보다싶이 insert 구문을 쓰기 전까지는 테이블이 생성된 걸 h2-console에서 확인할 수 있었습니다 ㅠㅠ 그런데 data.sql만 생성하고 insert하려고 하면 갑자기 테이블이 없다고 뜨네요 ....
yml 파일이고
spring:
jpa:
show-sql: true
hibernate:
ddl-auto: create
defer-datasource-initialization: true
messages:
basename: messages
mvc:
pathmatch:
matching-strategy: ant_path_matcher
#h2 console 활성화
h2:
console:
enabled: true
#원격접속 허용
settings:
web-allow-others: true
# 경로
path: /h2-console
#유일한 이름 생성 여부
datasource:
generate-unique-name: false
#url 경로
url: jdbc:h2:mem:testdb
#class 명칭
driver-class-name: org.h2.Driver
pom 파일입니다
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.200</version>
<scope>runtime</scope> <!-- RUNTIME 에서만 실행 -->
</dependency>
답변 1
0
안녕하세요, 이도원입니다.
Hibernate가 초기화 되기 전에 data.sql이 실행되어서 테이블이 존재하지 않는다는 오류가 발생한 것 같습니다. data.sql 파일과 같은 위치에 schema.sql 파일을 생성한 다음, create table로 테이블을 생성하시거나, application.yml 파일에 아래와 같은 설정으로 테이블을 생성할 수도 있습니다.
spring.jpa.defer-datasource-initialization: true

감사합니다.
JPA
0
71
1
jpa dependency를 추가하고 SecurityConfig클래스에서 오류가 납니다.
0
84
1
웹 브라우저 400 bad request
0
87
1
@Size는 되는데 @Past는 안 됩니다.
0
77
1
pdf 자료는 없나요?
0
94
2
locale 정보가 null 이면 무조건 messages_ko.properties이 호출 되는 문제
0
103
2
Swagger 강의, Unable to infer base url 이거 뜨시는 분들 도움되시라고
0
136
1
강의에서나온 화면 피피티
0
169
1
HelloWorldBean 관련 에러
0
194
2
Swagger API 3.x 오류..
0
231
1
java: variable message not initialized in the default constructor 에러는 어찌하면 좋을까요?
1
292
1
현재 GIT에 올리신 소스를 실행해봤습니다.
0
203
2
고양이 소리가 귀엽네요 !!
0
150
2
git에서 소스받고 실습중인데
0
129
1
post가 안되요
0
119
1
한국어 같은 경우 언어코드인 messages_ko.properties 로 생성하는게 더 좋지 않나요?
0
177
2
리턴타입으로서 EntityModel<User> 와 ResponseEntity질문
0
113
1
예외처리쪽 관련 질문있습니다.
0
165
2
엔티티가 바로 응답으로 나가도 되나요??
0
239
2
안녕하세여 Cannot invoke "co.kr.joneconsulting.resfulservice.repository.PostRepository.save(Object)" because "this.postRepository" is null
0
151
2
사용자 등록하고 나서 H2 에서 보면 신규 사용자의 password, ssn 이 null 로 되어 있습니다.
0
146
2
ApplictionContext 질문
0
199
2
롬북이 안먹히는것같아요
0
162
1
인텔리제이에서스프링부트 파일 실행하면
0
244
1





