ジャクソン関連のプロジェクトを実行し、次の `JsonMerge`が見つかりませんというエラーになります。

コンソール

java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonMerge
    at com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector.<clinit>(JacksonAnnotationIntrospector.java:50) ~[jackson-databind-2.9.0.pr1.jar:2.9.0.pr1]    at com.fasterxml.jackson.databind.ObjectMapper.<clinit>(ObjectMapper.java:292) ~[jackson-databind-2.9.0.pr1.jar:2.9.0.pr1]    at com.hostingcompass.core.utils.PrintUtils.<clinit>(PrintUtils.java:9) ~[main/:na]    at com.hostingcompass.app.run.TurtleApp.run(TurtleApp.java:25) ~[main/:na]    at com.hostingcompass.app.Main.run(Main.java:42)[main/:na]    at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:776)[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]    at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:760)[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]    at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:747)[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162)[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151)[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]    at com.hostingcompass.app.Main.main(Main.java:34)[main/:na]    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0__77]    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0__77]    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0__77]    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0__77]    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)[idea__rt.jar:na]Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.annotation.JsonMerge
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0__77]    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0__77]    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0__77]    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0__77]    ... 17 common frames omitted

解決策

これを修正するには、Jacksonをバージョン2.8.xにダウングレードし、最新の

2.9.0.pr1`はまだ安定していません。 Gradleの場合、 `dependencyInsight`を使用して

jackson-databind`関係を調べます。

ターミナル

$ gradle dependencyInsight --configuration compile --dependency jackson-databind

com.fasterxml.jackson.core:jackson-databind:2.9.0.pr1 (conflict resolution)

com.fasterxml.jackson.core:jackson-databind:2.8.2 -> 2.9.0.pr1
\--- com.maxmind.geoip2:geoip2:2.8.0
     \--- compile

com.fasterxml.jackson.core:jackson-databind:2.8.7 -> 2.9.0.pr1
\--- compile

com.fasterxml.jackson.core:jackson-databind:[2.7.0,) -> 2.9.0.pr1
\--- com.maxmind.db:maxmind-db:1.2.1
     \--- com.maxmind.geoip2:geoip2:2.8.0
          \--- compile

これを修正するには、

jackson-databind`を

com.maxmind.geoip2`から除外してください:

build.gradle

dependencies {
    compile "com.fasterxml.jackson.core:jackson-databind:2.8.7"
    compile ('com.maxmind.geoip2:geoip2:2.8.0'){
        exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'
    }
}

参考文献

JsonMerge#119用]。リンク://gradle/gradle-display-project-dependency/[Gradle – 表示

プロジェクトの依存関係]

リンク://タグ/依存関係/[依存関係]リンク://タグ/geoip2/[geoip2]

gradle


jackson