728x90
H2 데이터베이스 2.1.212 버전에서는 user 키워드가 예약어로 지정되어 있어서 user 테이블 생성이 안되고 아래와 같은 에러가 발생합니다.
오류메세지
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "\000d\000a create table [*]user (\000d\000a id bigint generated by default as identity,\000d\000a created_date timestamp,\000d\000a modified_date timestamp,\000d\000a email varchar(255) not null,\000d\000a name varchar(255) not null,\000d\000a picture varchar(255),\000d\000a role varchar(255) not null,\000d\000a primary key (id)\000d\000a )"; expected "identifier"; SQL statement:
해결 방법1) - H2 버전 변경
H2 2.1.212 -> 1.4.200 으로 버전을 변경해서 사용합니다.
해결 방법2) - H2 설정 변경
application.properties 에서 spring.datasource.url 에 NON_KEYWORDS=USER 설정을 추가합니다.
# DATABASE (H2)
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
spring.datasource.url=jdbc:h2:~/testDB;NON_KEYWORDS=USER
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=
spring.datasource.password=
해결 방법3) 테이블 이름 변경 (user -> users)
@Table(name = "users")
728x90
'SpringBoot' 카테고리의 다른 글
스프링 시큐리티를 사용한 소셜로그인(Google) 기능구현 2 (0) | 2022.10.08 |
---|---|
스프링 시큐리티를 사용한 소셜로그인(Google) 기능구현 1 (0) | 2022.10.08 |
IntelliJ properties 파일 한글 깨짐 현상 (0) | 2022.08.29 |
IntelliJ + mustache 사용 시 한글 깨짐 (0) | 2022.08.29 |
IntelliJ Gradle Project 'finished with non-zero exit value 1' 에러 (0) | 2022.08.19 |