ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Spring WebFlux 사용시 InvalidDefinitionException 처리 방법
    Back-end Engineering 2020. 12. 5. 20:04

    start.spring.io에서 WebFlux를 다운로드 받아서 기본적인 세팅을 하고 실행하는데 아래 에러가 나온다. 그래서 검색해보니 web과 webflux 모듈이 충돌이 나는듯 하다. 그래서 해결책은 web 제거! 끝.

     

    에러: 

    com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `reactor.core.publisher.Mono` (no Creators, like default constructor, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
     at [Source: (PushbackInputStream); line: 1, column: 1]
     	at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:67) ~[jackson-databind-2.11.3.jar:2.11.3]
    	at com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1615) ~[jackson-databind-2.11.3.jar:2.11.3]
    	at com.fasterxml.jackson.databind.DatabindContext.reportBadDefinition(DatabindContext.java:400) ~[jackson-databind-2.11.3.jar:2.11.3]
    	at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1077) ~[jackson-databind-2.11.3.jar:2.11.3]
    	at com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserialize(AbstractDeserializer.java:265) ~[jackson-databind-2.11.3.jar:2.11.3]
    	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4526) ~[jackson-databind-2.11.3.jar:2.11.3]
    	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3521) ~[jackson-databind-2.11.3.jar:2.11.3]
    	at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:274) ~[spring-web-5.3.1.jar:5.3.1]
    	at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.read(AbstractJackson2HttpMessageConverter.java:243) ~[spring-web-5.3.1.jar:5.3.1]
        .....

     

    해결책

    build.gradle에서 spring-boot-starter-web을 제거해라.

    implementation("org.springframework.boot:spring-boot-starter-web")

     

    Best Regards

    Hans

Designed by Tistory.