[Trouble Shooting] add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling
βοΈ μμ¬
Spring μ격 κ°μ μ€μ μ€νλ§μ 3κ³μΈ΅(Controller, Sevice, Repository) μμ΄
AllInOneServelet ν΄λμ€λ₯Ό μμ±νμ¬ κ΅¬ννκ³ , APIμ λμμ κ²μ¦νκΈ° μν μμ μ€ νΈλ¬λΈμ λ§λ¨!
ARCμμ POST APIλ₯Ό 보λμ λ, "Internal Server Error"
μλ¬ νμΈμ μν΄μ intellij μλ¬ μ½λ νμΈ
Servlet.service() for servlet [com.sparta.springcore.AllInOneServlet] in context with path [] threw exception
μλ¬ μ½λ μμ μλ μ λ¬Έμ₯λ§ μ κ²½ μ°λλΌ κ²½λ‘κ° μλͺ»λ μ€ μκ³ PC μΈμ΄ μ€μ λ³κ²½ν΄λ³΄κ³ λ리 ...
κ²°κ΅, νμλΆκ» λμμ μ²νλλ° ..!
λ°λ‘ μλ μ½λλ₯Ό νμΈνμ΄μΌνλ€.
βοΈ Trouble
Java 8 date/time type `java.time.LocalDateTime` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: com.sparta.springcore.Product["createdAt"])
β¨ ν΄κ²° μ°Έκ³ μλ£
βοΈ μμΈ
Since Jackson 2.6.0 the "old" JSR310Module is deprecated.
It is replaced by JavaTimeModule. Maven dependency is the same (you can find the current version in Maven Central):
(λ²μ) Jackson 2.6.0λΆν° "μ΄μ " JSR310Moduleμ λ μ΄μ μ¬μ©λμ§ μμ΅λλ€.
JavaTimeModuleλ‘ λ체λ©λλ€. Maven μ’ μμ±μ λμΌν©λλ€(Maven Centralμμ νμ¬ λ²μ μ μ°Ύμ μ μμ).
=> Java 8 κ³Όμ λ²μ λ¬Έμ ...
βοΈ ν΄κ²°
(1) MVN Repositoryμμ "Jackson Datatype" λ₯Ό κ²μν΄μ 'build.gradle - dependencies'μ λΆμ¬μ£ΌκΈ°
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.2'
(2) AllInOneServlet.java ν΄λμ€μμ μλ μ½λλ₯Ό μ°Ύμμ,
ObjectMapper objectMapper = new ObjectMapper();
μλ μ½λλ₯Ό λΆμ¬μ£ΌκΈ° (μ¬λ¬ κ° μμμ)
objectMapper.registerModule(new JavaTimeModule());
βοΈ ν΄κ²° μλ£ !