天天看點

springboot jackson錯誤Could not initialize class com.fasterxml.jackson.databind.Ob

Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.fasterxml.jackson.databind.ObjectMapper at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.build(Jackson2ObjectMapperBuilder.java:606) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.(MappingJackson2HttpMessageConverter.java:59) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter.(AllEncompassingFormHttpMessageConverter.java:74) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.web.filter.HttpPutFormContentFilter.(HttpPutFormContentFilter.java:64) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.boot.web.servlet.filter.OrderedHttpPutFormContentFilter.(OrderedHttpPutFormContentFilter.java:29) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration.httpPutFormContentFilter(WebMvcAutoConfiguration.java:163) ~[spring-boot-autoconfigure-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$$EnhancerBySpringCGLIB$$e7a30b6.CGLIB$httpPutFormContentFilter

springboot jackson錯誤Could not initialize class com.fasterxml.jackson.databind.Ob
springboot jackson錯誤Could not initialize class com.fasterxml.jackson.databind.Ob
springboot jackson錯誤Could not initialize class com.fasterxml.jackson.databind.Ob
springboot jackson錯誤Could not initialize class com.fasterxml.jackson.databind.Ob
springboot jackson錯誤Could not initialize class com.fasterxml.jackson.databind.Ob

BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$$EnhancerBySpringCGLIB$$e7a30b6.httpPutFormContentFilter() ~[spring-boot-autoconfigure-2.0.3.RELEASE.jar:2.0.3.RELEASE] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_161] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_161] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_161] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_161] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] ... 25 common frames omitted

之前的pom 配置是

<!--jackson-->
       <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.12</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-core-asl</artifactId>
            <version>1.9.12</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>2.7.5</version>
        </dependency>
複制代碼
           

修改後的pom

<dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</artifactId>
        </dependency>
複制代碼
           

正常了