inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발

data.sql 자동 저장이 되지 않습니다

410

Architect

작성한 질문수 7

0

자동 저장이 되지 않아 계속 수동으로 INSERT를 해주었는데요.

수동으로 잘 수행이 됐으니 INSERT 문에는 문제가 없을 것 같고(세미콜론도 넣었습니다.),

yml 파일의 설정이 뭔가 잘못된 걸까요?

의심가는 부분이 있으실지요?

스프링부트 버전은 2.5.5입니다.

H2도 mem.testdb가 잘 되지 않아 이렇게 저렇게 해보다가 설정파일은 다음과 같이 되었습니다.

spring:
  application:
    name: catalog-service
  messages:
    basename: messages
  # JPA
  jpa:
    hibernate:
      ddl-auto: create-drop
    show-sql: true
    generate-ddl: true
    defer-datasource-initialization: true
#  h2:
#    console:
#      enabled: true
#      settings:
#        web-allow-others: true
#      path: /h2-console
  datasource:
#    url: jdbc:h2:tcp://localhost:8082/~/testdb
    url: jdbc:h2:~/testdb
    username: sa
    password:
    driver-class-name: org.h2.Driver

spring-boot rest-api

답변 1

0

Architect

자문자답입니다.

인메모리와 아닌 경우를 다르게 취급할 거라고는 상상도 못했네요.

https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto.data-initialization

By default, SQL database initialization is only performed when using an embedded in-memory database. To always initialize an SQL database, irrespective of its type, set spring.sql.init.mode to always. Similarly, to disable initialization, set spring.sql.init.mode to never.

JPA

0

60

1

jpa dependency를 추가하고 SecurityConfig클래스에서 오류가 납니다.

0

70

1

웹 브라우저 400 bad request

0

73

1

@Size는 되는데 @Past는 안 됩니다.

0

62

1

pdf 자료는 없나요?

0

75

2

locale 정보가 null 이면 무조건 messages_ko.properties이 호출 되는 문제

0

90

2

Swagger 강의, Unable to infer base url 이거 뜨시는 분들 도움되시라고

0

120

1

강의에서나온 화면 피피티

0

160

1

HelloWorldBean 관련 에러

0

187

2

Swagger API 3.x 오류..

0

222

1

java: variable message not initialized in the default constructor 에러는 어찌하면 좋을까요?

1

283

1

현재 GIT에 올리신 소스를 실행해봤습니다.

0

189

2

고양이 소리가 귀엽네요 !!

0

139

2

git에서 소스받고 실습중인데

0

119

1

post가 안되요

0

106

1

한국어 같은 경우 언어코드인 messages_ko.properties 로 생성하는게 더 좋지 않나요?

0

169

2

리턴타입으로서 EntityModel<User> 와 ResponseEntity질문

0

106

1

예외처리쪽 관련 질문있습니다.

0

160

2

엔티티가 바로 응답으로 나가도 되나요??

0

224

2

안녕하세여 Cannot invoke "co.kr.joneconsulting.resfulservice.repository.PostRepository.save(Object)" because "this.postRepository" is null

0

140

2

사용자 등록하고 나서 H2 에서 보면 신규 사용자의 password, ssn 이 null 로 되어 있습니다.

0

143

2

ApplictionContext 질문

0

195

2

롬북이 안먹히는것같아요

0

158

1

인텔리제이에서스프링부트 파일 실행하면

0

241

1