Spring

Cannot parse "TIMESTAMP" constant 에러

상일동 2023. 5. 23. 18:50

개발 환경: spring 2.7.11, java 11, h2 2.1.214

 

오류 메시지:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/C:/Programming/Crud/build/resources/main/data.sql]: INSERT INTO `user`(USER_ID,USERNAME,PASSWORD,NICKNAME,AGE,CREATEAT) VALUES(1,'이름', 1234,'닉네임',24,'2023-05-18 19:17:00:000'); nested exception is org.h2.jdbc.JdbcSQLDataException: Cannot parse "TIMESTAMP" constant "2023-05-18 19:17:00:000"; SQL statement:
INSERT INTO `user`(USER_ID,USERNAME,PASSWORD,NICKNAME,AGE,CREATEAT) VALUES(1,'이름', 1234,'닉네임',24,'2023-05-18 19:17:00:000') [22007-214]

시간을 입력값으로 못받아 들인다...

 

gpt 말로는 columnDefinition = "TIMESTAMP" 추가하라고 하는데 내 경우에는 이래도 해결이 안 됐다.

 

뒤에 :000을 지워주니 해결되는 모습.. 

LocalDateTime은  "YYYY-MM-DDTHH:MM:SS" 형태로 내뱉는데 난 왜 뒤에 :sss를 왜 붙였지..