1 ๋ถ„ ์†Œ์š”

์—๋Ÿฌ ์ฝ”๋“œ

Error while extracting response for type [class java.lang.Long] and content type [application/json;charset=UTF-8]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of java.lang.Long out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of java.lang.Long out of START_OBJECT token
at [Source: (PushbackInputStream); line: 1, column: 1]
org.springframework.web.client.RestClientException: Error while extracting response for type [class java.lang.Long] and content type [application/json;charset=UTF-8]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of java.lang.Long out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of java.lang.Long out of START_OBJECT token
at [Source: (PushbackInputStream); line: 1, column: 1]

org.hibernate.dialect.MySQL5InnoDBDialect

์Šคํ”„๋ง๋ถ€ํŠธ์™€ AWS๋กœ ํ˜ผ์ž ๊ตฌํ˜„ํ•˜๋Š” ์›น ์„œ๋น„์Šค ์ฑ…์„ ๋”ฐ๋ผ ํ•™์Šตํ•˜๋‹ค ๋ณด๋‹ˆ, application.properties ํŒŒ์ผ์— spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect ์ด๋ผ๋Š” ์„ค์ •์„ ์ถ”๊ฐ€ํ•ด์ค€๋‹ค.

์ด ์„ค์ •์˜ ์˜๋ฏธ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.
spring.jpa.properties.hibernate.dialect๋Š” MySQL ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์™€ ์ƒํ˜ธ์ž‘์šฉํ•  ๋•Œ ์‚ฌ์šฉํ•  Hibernate ์–ธ์–ด๋ฅผ ์ง€์ •ํ•œ๋‹ค๋Š” ์˜๋ฏธ์ด๋‹ค.
Hibernate๊ฐ€ SQL๋ฌธ์„ ์ƒ์„ฑํ•˜๊ณ , ๊ธฐ๋ณธ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์™€ ์ƒํ˜ธ์ž‘์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๊ฒฐ์ •ํ•œ๋‹ค.

org.hibernate.dialect.MySQL5InnoDBDialect๋Š” Hibernate๊ฐ€ MySQL ๋ฒ„์ „ 5๊ณผ ์ƒํ˜ธ์ž‘์šฉํ•œ๋‹ค๋Š” ์˜๋ฏธ์ด๋‹ค.
์ฆ‰, ํ˜ธํ™˜ํ•˜๋Š” MySQL์˜ ๋ฒ„์ „์ด 5๋ผ๋Š” ๋œป์ด๋‹ค.

์—๋Ÿฌ ๋ฐœ์ƒ ๋ฐ ํ•ด๊ฒฐ

application.properties์— spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialectspring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect ์ด ์„ค์ •์„ ํ•œ ํ›„์—, ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•ด๋ณด๋ฉด ์„ค์ •์„ ์ถ”๊ฐ€ํ•˜๊ธฐ ์ „์—๋Š” ์ •์ƒ์ ์œผ๋กœ ๋™์ž‘ํ•˜๋˜ ์ฝ”๋“œ๊ฐ€ ๊ฐ‘์ž๊ธฐ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•จ๊ณผ ๋™์‹œ์— ์ •์ƒ ๋™์ž‘ํ•˜์ง€ ์•Š๋Š”๋‹ค.

์ด ๊ฒฝ์šฐ์— ๋‚˜์˜ MySQL ๋ฒ„์ „์„ ๋จผ์ € ํ™•์ธํ•˜๋ฉด ๋œ๋‹ค.
๋‚˜์˜ MySQL ๋ฒ„์ „ ํ™•์ธ ๋ฐฉ๋ฒ•์€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

[application.properties]

spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL57Dialect
spring.jpa.properties.hibernate.dialect.storage_engine=innodb
spring.datasource.hikari.jdbc-url=jdbc:h2:mem://localhost/~/test;MODE=MYSQL
spring.h2.console.enabled=true

์œ„ ์„ค์ •์—์„œ jdbc:h2:mem://localhost/~/test๋ถ€๋ถ„์€ ๋ณธ์ธ์˜ h2 ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๊ฒฝ๋กœ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ๋œ๋‹ค.

์ฐธ๊ณ ์ž๋ฃŒ

https://github.com/jojoldu/freelec-springboot2-webservice/issues/612

https://herojoon-dev.tistory.com/166

ํƒœ๊ทธ:

์นดํ…Œ๊ณ ๋ฆฌ:

์—…๋ฐ์ดํŠธ:

๋Œ“๊ธ€๋‚จ๊ธฐ๊ธฐ