我正在嘗試將Java版本從1.7
升級到1.8
。 除了在Maven插件中將目標版本升級到1.8以外,未更改任何代碼。Jackson Object Mapper從Java 7到Java 8的版本問題
Error: cannot access Versioned
。
來源:
private ObjectMapper mapper = new ObjectMapper();
return mapper.writeValueAsString(data);
無法在互聯網上找到任何地方的任何文件。我認爲1.8
應該完全向後兼容。
編輯: 甚至沒有改變pom,如果我將我的本地maven設置爲Java 8,它仍然是打破。因此,與Java編譯8是有問題:(
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.2.2:compile
[INFO] | +- org.codehaus.jackson:jackson-core-asl:jar:1.1.0:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.2.2:compile
[INFO] +- com.fasterxml:jackson-xml-databind:jar:0.6.2:compile
[INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.2:compile
[INFO] | +- org.codehaus.jackson:jackson-xc:jar:1.9.2:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.2.2:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.2.2:compile
[INFO] | +- org.codehaus.jackson:jackson-core-asl:jar:1.1.0:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.2.2:compile
[INFO] +- com.fasterxml:jackson-xml-databind:jar:0.6.2:compile
[INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.2:compile
[INFO] | +- org.codehaus.jackson:jackson-xc:jar:1.9.2:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.2.2:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.2.2:compile
[INFO] | +- org.codehaus.jackson:jackson-core-asl:jar:1.1.0:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.2.2:compile
[INFO] +- com.fasterxml:jackson-xml-databind:jar:0.6.2:compile
[INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.2:compile
[INFO] | +- org.codehaus.jackson:jackson-xc:jar:1.9.2:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.2.2:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.2.2:compile
[INFO] | +- org.codehaus.jackson:jackson-core-asl:jar:1.1.0:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.2.2:compile
[INFO] +- com.fasterxml:jackson-xml-databind:jar:0.6.2:compile
[INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.2:compile
[INFO] | +- org.codehaus.jackson:jackson-xc:jar:1.9.2:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.2.2:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.2.2:compile
[INFO] | +- org.codehaus.jackson:jackson-core-asl:jar:1.1.0:compile
[INFO] | +- org.codehaus.jackson:jackson-jaxrs:jar:1.9.11:compile
[INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.11:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.2.2:compile
[INFO] +- com.fasterxml:jackson-xml-databind:jar:0.6.2:compile
[INFO] | +- org.codehaus.jackson:jackson-xc:jar:1.9.2:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.2.2:compile
[INFO] +- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile
[INFO] | | +- org.codehaus.jackson:jackson-jaxrs:jar:1.9.11:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.6.0-rc2:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.2.2:compile
[INFO] +- com.fasterxml:jackson-xml-databind:jar:0.6.2:compile
[INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.2:compile
[INFO] | +- org.codehaus.jackson:jackson-xc:jar:1.9.2:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.2.2:compile
-X輸出:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project my-module: Compilation failure
[ERROR] /Users/xxxxxx/MyApp.java:[52,15] error: cannot access Versioned
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project myntra-orch-lms: Compilation failure
/Users/xxxxxx/MyApp.java:[52,15] error: cannot access Versioned
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
/Users/xxxxxx/MyApp.java:[52,15] error: cannot access Versioned
at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:656)
at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
嗯,你不應該[開一個問題](https://github.com/FasterXML/jackson-databind/issues)而不是? – fge
@fge,我不確定是傑克遜問題還是其他一些我不知道的真正問題。在我提出問題之前知道最好知道 – Reddy
對我來說,它肯定聽起來像一個bug。正如你所說,沒有理由更新JDK會導致你的代碼失敗。但是,這是你的決定,當然;) – fge