本文的目的是介绍Jackson注释JsonFormat$Valuejsonjava.lang.NoSuchMethodError的详细情况,特别关注jackson注解解析json的相关信息。我们将通过
本文的目的是介绍Jackson注释JsonFormat $Value json java.lang.NoSuchMethodError的详细情况,特别关注jackson注解解析json的相关信息。我们将通过专业的研究、有关数据的分析等多种方式,为您呈现一个全面的了解Jackson注释JsonFormat $Value json java.lang.NoSuchMethodError的机会,同时也不会遗漏关于ava.lang.NoSuchMethodError: scala.Predef$.ArrowAssoc(Ljava/lang/Object;)Ljava/lang/Object;、com.fasterxml.jackson.databind.jsonFormatVisitors.JsonValueFormat的实例源码、fastjson报NoSuchMethodError诡异、Gson2.8.6 版本报错 java.lang.NoSuchMethodError: com.google.gson.JsonParser.parseString (Ljava/lang/String;)的知识。
本文目录一览:- Jackson注释JsonFormat $Value json java.lang.NoSuchMethodError(jackson注解解析json)
- ava.lang.NoSuchMethodError: scala.Predef$.ArrowAssoc(Ljava/lang/Object;)Ljava/lang/Object;
- com.fasterxml.jackson.databind.jsonFormatVisitors.JsonValueFormat的实例源码
- fastjson报NoSuchMethodError诡异
- Gson2.8.6 版本报错 java.lang.NoSuchMethodError: com.google.gson.JsonParser.parseString (Ljava/lang/String;)
Jackson注释JsonFormat $Value json java.lang.NoSuchMethodError(jackson注解解析json)
我在我的gradle项目中使用com.fasterxml.jackson.core:jackson-annotations:2.6.0.由于将com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.6.0添加到我的项目构建文件中,我在运行gradle项目时遇到了这个异常.这是我的错误的堆栈跟踪.
Caused by: org.springframework.beans.BeanInstantiationException:
Failed to instantiate
[org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]:
Constructor threw exception; nested exception is
java.lang.NoSuchMethodError:
com.fasterxml.jackson.annotation.JsonFormat$Value.empty()Lcom/fasterxml/jackson/annotation/JsonFormat$Value;
at
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163)
at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:89)
at
org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.instantiateBean(AbstractAutowireCapablebeanfactory.java:1098)
… 117 more Caused by: java.lang.NoSuchMethodError:
com.fasterxml.jackson.annotation.JsonFormat$Value.empty()Lcom/fasterxml/jackson/annotation/JsonFormat$Value;
at
com.fasterxml.jackson.databind.cfg.MapperConfig.(MapperConfig.java:50)
at
com.fasterxml.jackson.databind.ObjectMapper.(ObjectMapper.java:535)
at
com.fasterxml.jackson.databind.ObjectMapper.(ObjectMapper.java:452)
at
org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.build(Jackson2ObjectMapperBuilder.java:553)
at
org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.(MappingJackson2HttpMessageConverter.java:57)
at
org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter.(AllEncompassingFormHttpMessageConverter.java:61)
at
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.(RequestMappingHandlerAdapter.java:187)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method) at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
… 119 more nested in
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name
‘org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter’:
Instantiation of bean Failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to
instantiate
[org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]:
Constructor threw exception; nested exception is
java.lang.NoSuchMethodError:
com.fasterxml.jackson.annotation.JsonFormat$Value.empty()Lcom/fasterxml/jackson/annotation/JsonFormat$Value;:
java.lang.NoSuchMethodError:
com.fasterxml.jackson.annotation.JsonFormat$Value.empty()Lcom/fasterxml/jackson/annotation/JsonFormat$Value;
at
com.fasterxml.jackson.databind.cfg.MapperConfig.(MapperConfig.java:50)
at
com.fasterxml.jackson.databind.ObjectMapper.(ObjectMapper.java:535)
at
com.fasterxml.jackson.databind.ObjectMapper.(ObjectMapper.java:452)
at
org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.build(Jackson2ObjectMapperBuilder.java:553)
at
org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.(MappingJackson2HttpMessageConverter.java:57)
at
org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter.(AllEncompassingFormHttpMessageConverter.java:61)
at
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.(RequestMappingHandlerAdapter.java:187)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method) at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:89)
at
org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.instantiateBean(AbstractAutowireCapablebeanfactory.java:1098)
at
org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.createBeanInstance(AbstractAutowireCapablebeanfactory.java:1050)
at
org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.doCreateBean(AbstractAutowireCapablebeanfactory.java:510)
at
org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.createBean(AbstractAutowireCapablebeanfactory.java:482)
at
org.springframework.beans.factory.support.Abstractbeanfactory$1.getobject(Abstractbeanfactory.java:306)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at
org.springframework.beans.factory.support.Abstractbeanfactory.doGetBean(Abstractbeanfactory.java:302)
at
org.springframework.beans.factory.support.Abstractbeanfactory.getBean(Abstractbeanfactory.java:197)
at
org.springframework.beans.factory.support.DefaultListablebeanfactory.preInstantiateSingletons(DefaultListablebeanfactory.java:772)
at
org.springframework.context.support.AbstractApplicationContext.finishbeanfactoryInitialization(AbstractApplicationContext.java:839)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at
org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
at
org.springframework.web.context.ContextLoaderListener.contextinitialized(ContextLoaderListener.java:107)
at
org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
at
org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1272)
at
org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
at
org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:489)
at
org.gradle.api.plugins.jetty.internal.JettyPluginWebAppContext.doStart(JettyPluginWebAppContext.java:112)
at
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at
org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
at
org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
at
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at
org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
at
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at
org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.Server.doStart(Server.java:224) at
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at
org.gradle.api.plugins.jetty.internal.Jetty6PluginServer.start(Jetty6PluginServer.java:111)
at
org.gradle.api.plugins.jetty.AbstractJettyRunTask.startJettyInternal(AbstractJettyRunTask.java:238)
at
org.gradle.api.plugins.jetty.AbstractJettyRunTask.startJetty(AbstractJettyRunTask.java:191)
at
org.gradle.api.plugins.jetty.AbstractJettyRunTask.start(AbstractJettyRunTask.java:162)
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.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75) at
org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:227)
at
org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:220)
at
org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:209)
at
org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:585)
at
org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:568)
at
org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at
org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
at
org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at
org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at
org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
at
org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at
org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
at
org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at
org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
at
org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at
org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
at
org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
at
org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processtask(AbstractTaskPlanExecutor.java:66)
at
org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
at
org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25)
at
org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110)
at
org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
at
org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
at
org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
at
org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
at
org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
at
org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
at
org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
at
org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:154)
at org.gradle.internal.Factories$1.create(Factories.java:22) at
org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at
org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)
at
org.gradle.initialization.DefaultGradleLauncher.dobuildStages(DefaultGradleLauncher.java:151)
at
org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
at
org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:99)
at
org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:93)
at
org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at
org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)
at
org.gradle.initialization.DefaultGradleLauncher.dobuild(DefaultGradleLauncher.java:93)
at
org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82)
at
org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94)
at
org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:46)
at
org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at
org.gradle.tooling.internal.provider.runner.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:58)
at
org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at
org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43)
at
org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
at
org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75)
at
org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:45)
at
org.gradle.launcher.daemon.server.exec.ExecuteBuild.dobuild(ExecuteBuild.java:52)
at
org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at
org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at
org.gradle.launcher.daemon.server.exec.WatchFordisconnection.execute(WatchFordisconnection.java:37)
at
org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at
org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
at
org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at
org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
at
org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at
org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
at
org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
at org.gradle.util.Swapper.swap(Swapper.java:38) at
org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
at
org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at
org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:47)
at
org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at
org.gradle.launcher.daemon.server.exec.LogToClient.dobuild(LogToClient.java:66)
at
org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at
org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at
org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.dobuild(EstablishBuildEnvironment.java:72)
at
org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at
org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at
org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41)
at
org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at
org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
at
org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:246)
at
org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at
org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
我在课堂上没用过@JsonFormat.但我确实有JsonSerializer和JsonDeserializer注释使用两个类来序列化和反序列化我的zoneddatetime与UTC中的Json.我是第一次进行序列化和反序列化,所以请提出任何建议.
这是我的gradle文件代码:
apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'jetty' apply plugin: 'maven' apply plugin: 'war'
ext { springVersion = "4.2.4.RELEASE" springSecurityVersion = "4.0.3.RELEASE" }
repositories { mavenLocal() mavenCentral()
/* maven {
url "http://repo.typesafe.com/typesafe/releases/"
} */ }
configurations.all { exclude group: "commons-logging",module: "commons-logging" exclude group: "log4j",module: "log4j" }
dependencies { compile 'org.slf4j:jcl-over-slf4j:1.7.12' compile 'ch.qos.logback:logback-classic:1.1.3' compile "org.springframework:spring-core:$springVersion" compile "org.springframework:spring-context:$springVersion"
compile ("org.springframework:spring-web:$springVersion"){
exclude group: "com.fasterxml.jackson.core" } compile ("org.springframework:spring-webmvc:$springVersion"){
exclude group: "com.fasterxml.jackson.core" } compile "org.springframework:spring-orm:$springVersion" compile "org.springframework.security:spring-security-web:$springSecurityVersion" compile "org.springframework.security:spring-security-config:$springSecurityVersion"
compile "org.aspectj:aspectjrt:1.7.4"
compile "org.hibernate:hibernate-core:4.3.6.Final" compile "org.hibernate:hibernate-entitymanager:4.3.6.Final" compile "javax.servlet:javax.servlet-api:3.1.0" compile "org.javassist:javassist:3.15.0-GA" compile "MysqL:mysql-connector-java:5.1.31"
compile "org.hsqldb:hsqldb:2.3.2"
compile "commons-dbcp:commons-dbcp:1.2.2" compile "org.apache.commons:commons-lang3:3.4" compile 'com.fasterxml.jackson.core:jackson-annotations:2.7.0' compile 'com.fasterxml.jackson.core:jackson-core:2.7.0' compile 'com.fasterxml.jackson.core:jackson-databind:2.7.0' compile 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.7.0'
compile "net.sf.ehcache:ehcache-core:2.6.9" compile "org.hibernate:hibernate-ehcache:4.3.5.Final" compile "com.h2database:h2:1.4.177" compile "com.google.code.gson:gson:2.6.2"
testCompile ("junit:junit:4.12"){
exclude group: "org.hamcrest" } testCompile "org.springframework:spring-test:$springVersion" testCompile "org.easetech:easytest-core:1.4.0" testCompile "org.mockito:mockito-core:1.9.5" testCompile "org.hamcrest:hamcrest-all:1.3" testCompile "com.jayway.jsonpath:json-path:2.2.0" testCompile "com.jayway.jsonpath:json-path-assert:2.2.0"
testRuntime "org.hsqldb:hsqldb:2.3.2" }
http://fasterxml.github.io/jackson-annotations/javadoc/2.6/com/fasterxml/jackson/annotation/JsonFormat.Value.html
http://fasterxml.github.io/jackson-annotations/javadoc/2.7.0-rc1/com/fasterxml/jackson/annotation/JsonFormat.Value.html
尝试升级到2.7版.
ava.lang.NoSuchMethodError: scala.Predef$.ArrowAssoc(Ljava/lang/Object;)Ljava/lang/Object;
Exception in thread "main" java.lang.NoSuchMethodError: scala.Predef$.ArrowAssoc(Ljava/lang/Object;)Ljava/lang/Object;
at com.dt.scala.hello.TestMapFor$.main(MapFor.scala:32)
at com.dt.scala.hello.TestMapFor.main(MapFor.scala)
package com.dt.scala.hello
import java.io._
class MapFor(val xc: Int, val yc: Int) {
var x: Int = xc
var y: Int = yc
def move(dx: Int, dy: Int) {
x = x + dx
y = y + dy
println ("Yiibai x location : " + x);
println ("Yiibai y location : " + y);
}
}
object TestMapFor {
def main(args: Array[String]) {
val pt = new MapFor(10, 20);
println("---bookee45456465--")
// Move to a new location
pt.move(10, 10);
var sites = Map("runoob" -> "http://www.runoob.com",
"baidu" -> "http://www.baidu.com",
"taobao" -> "http://www.taobao.com")
sites + ("book"-> "test")
sites.keys.foreach{ i =>
print( "Key = " + i )
println(" Value = " + sites(i) )}
}
}
com.fasterxml.jackson.databind.jsonFormatVisitors.JsonValueFormat的实例源码
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper paramJsonFormatVisitorWrapper,JavaType paramJavaType) { boolean bool1 = this._useTimestamp; boolean bool2 = bool1; if ((!bool1) && (this._customFormat == null)) bool2 = paramJsonFormatVisitorWrapper.getProvider().isEnabled(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); if (bool2) { JsonIntegerFormatVisitor localJsonIntegerFormatVisitor = paramJsonFormatVisitorWrapper.expectIntegerFormat(paramJavaType); if (localJsonIntegerFormatVisitor != null) { localJsonIntegerFormatVisitor.numberType(JsonParser.NumberType.LONG); localJsonIntegerFormatVisitor.format(JsonValueFormat.UTC_MILLISEC); } return; } JsonStringFormatVisitor localJsonStringFormatVisitor = paramJsonFormatVisitorWrapper.expectStringFormat(paramJavaType); if (localJsonStringFormatVisitor != null) localJsonStringFormatVisitor.format(JsonValueFormat.DATE_TIME); }
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor,JavaType typeHint) { //todo: (ryan) add a format for the date in the schema? boolean asNumber = _useTimestamp; if (!asNumber) { if (_customFormat == null) { asNumber = visitor.getProvider().isEnabled(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); } } if (asNumber) { visitor.expectNumberFormat(typeHint).format(JsonValueFormat.UTC_MILLISEC); } else { visitor.expectStringFormat(typeHint).format(JsonValueFormat.DATE_TIME); } }
@Override protected void _acceptTimestampVisitor(JsonFormatVisitorWrapper visitor,JavaType typeHint) throws JsonMappingException { SerializerProvider provider = visitor.getProvider(); boolean useTimestamp = (provider != null) && useTimestamp(provider); if (useTimestamp) { super._acceptTimestampVisitor(visitor,typeHint); } else { JsonStringFormatVisitor v2 = visitor.expectStringFormat(typeHint); if (v2 != null) { v2.format(JsonValueFormat.DATE_TIME); } } }
@Override protected void _acceptTimestampVisitor(JsonFormatVisitorWrapper visitor,JavaType typeHint) throws JsonMappingException { JsonIntegerFormatVisitor v2 = visitor.expectIntegerFormat(typeHint); if (v2 != null) { v2.numberType(JsonParser.NumberType.LONG); SerializerProvider provider = visitor.getProvider(); if ((provider != null) && provider.isEnabled(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS)) { // big number,no more specific qualifier to use... } else { // otherwise good old Unix timestamp,in milliseconds v2.format(JsonValueFormat.UTC_MILLISEC); } } }
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor,JavaType typeHint) throws JsonMappingException { SerializerProvider provider = visitor.getProvider(); boolean useTimestamp = (provider != null) && useTimestamp(provider); if (useTimestamp) { _acceptTimestampVisitor(visitor,typeHint); } else { JsonStringFormatVisitor v2 = visitor.expectStringFormat(typeHint); if (v2 != null) { v2.format(JsonValueFormat.DATE_TIME); } } }
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor,typeHint); } else { JsonStringFormatVisitor v2 = visitor.expectStringFormat(typeHint); if (v2 != null) { v2.format(JsonValueFormat.DATE); } } }
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper paramJsonFormatVisitorWrapper,JavaType paramJavaType) { JsonStringFormatVisitor localJsonStringFormatVisitor1; if (paramJsonFormatVisitorWrapper == null) localJsonStringFormatVisitor1 = null; else localJsonStringFormatVisitor1 = paramJsonFormatVisitorWrapper.expectStringFormat(paramJavaType); JsonStringFormatVisitor localJsonStringFormatVisitor2 = localJsonStringFormatVisitor1; if (localJsonStringFormatVisitor1 != null) localJsonStringFormatVisitor2.format(JsonValueFormat.DATE_TIME); }
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper paramJsonFormatVisitorWrapper,JavaType paramJavaType) { JsonStringFormatVisitor localJsonStringFormatVisitor1; if (paramJsonFormatVisitorWrapper == null) localJsonStringFormatVisitor1 = null; else localJsonStringFormatVisitor1 = paramJsonFormatVisitorWrapper.expectStringFormat(paramJavaType); JsonStringFormatVisitor localJsonStringFormatVisitor2 = localJsonStringFormatVisitor1; if (localJsonStringFormatVisitor1 != null) localJsonStringFormatVisitor2.format(JsonValueFormat.DATE_TIME); }
static JsonSchema schemaFor(final JDBCType jdbcType) { final JsonSchemaFactory factory = new JsonSchemaFactory(); switch (jdbcType) { case ARRAY: return factory.arraySchema(); case BINARY: case BLOB: case LONGVARBINARY: case VARBINARY: final ArraySchema binary = factory.arraySchema(); binary.setItemsSchema(factory.integerSchema()); return binary; case BIT: case BOOLEAN: return factory.booleanSchema(); case CHAR: case CLOB: case DATALINK: case LONGNVARCHAR: case LONGVARCHAR: case NCHAR: case NCLOB: case NVARCHAR: case ROWID: case sqlXML: case VARCHAR: return factory.stringSchema(); case DATE: case TIME: case TIMESTAMP: case TIMESTAMP_WITH_TIMEZONE: case TIME_WITH_TIMEZONE: final StringSchema date = factory.stringSchema(); date.setFormat(JsonValueFormat.DATE_TIME); return date; case DECIMAL: case DOUBLE: case FLOAT: case NUMERIC: case REAL: return factory.numberSchema(); case INTEGER: case BIGINT: case SMALLINT: case tinyint: return factory.integerSchema(); case NULL: return factory.nullSchema(); case disTINCT: case JAVA_OBJECT: case OTHER: case REF: case REF_CURSOR: case STRUCT: default: return factory.anySchema(); } }
static JsonSchema schemaFor(final JDBCType jdbcType) { final JsonSchemaFactory factory = new JsonSchemaFactory(); switch (jdbcType) { case ARRAY: return factory.arraySchema(); case BINARY: case BLOB: case LONGVARBINARY: case VARBINARY: final ArraySchema binary = factory.arraySchema(); binary.setItemsSchema(factory.integerSchema()); return binary; case BIT: case BOOLEAN: return factory.booleanSchema(); case CHAR: case CLOB: case DATALINK: case LONGNVARCHAR: case LONGVARCHAR: case NCHAR: case NCLOB: case NVARCHAR: case ROWID: case sqlXML: case VARCHAR: return factory.stringSchema(); case DATE: case TIME: case TIMESTAMP: case TIMESTAMP_WITH_TIMEZONE: case TIME_WITH_TIMEZONE: final StringSchema date = factory.stringSchema(); date.setFormat(JsonValueFormat.DATE_TIME); return date; case DECIMAL: case DOUBLE: case FLOAT: case NUMERIC: case REAL: return factory.numberSchema(); case INTEGER: case BIGINT: case SMALLINT: case tinyint: return factory.integerSchema(); case NULL: return factory.nullSchema(); case disTINCT: case JAVA_OBJECT: case OTHER: case REF: case REF_CURSOR: case STRUCT: default: return factory.anySchema(); } }
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor,JavaType typeHint) { visitor.expectStringFormat(typeHint).format(JsonValueFormat.DATE_TIME); }
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor,JavaType typeHint) { visitor.expectStringFormat(typeHint).format(JsonValueFormat.DATE_TIME); }
fastjson报NoSuchMethodError诡异
一个神奇的bug,2017年的一个工程A依赖fastjson1.2.7编译出了一个jar包,fastjson中有一个类SerializeConfig,这个类继承了一个put(Object k,Object v)的方法,所以编译出的jar包字节码里写的方法签名就是descriptor: (Ljava/lang/Object;Ljava/lang/Object;)Z。现在一个工程B使用工程A编译出的jar包,但是工程B里有fastjson的依赖1.2.60,在1.2.7之后(确切版本不知道),SerializeConfig这个类不再继承别人了,自己写了一个put(Type type, ObjectSerializer value),一个put(Object type, Object value),这时候有两个put方法。但是在fastjson1.2.60时,作者一不小心,删除了put(Object type,Object value)方法,导致运行时报NoSuchMethodError,注意时Error,不是Exception,在1.2.61,作者恢复了这个方法。 另外在研究这个错误的时候,发现有时候报NoClassDefFoundError,有时候报NoSuchMethodError,测试了一下,JVM在第一次加载出错类的时候,会报NoSuchMethodError,然后第二次再加载这个类的时候,直接报NoClassDefFoundError,不再尝试初始化了。
java.lang.NoSuchMethodError: com.alibaba.fastjson.serializer.SerializeConfig.put(Ljava/lang/Object;Ljava/lang/Object;)Z
at com.XX.bst.XX.common.annotation.XXX.<clinit>(XXXX)
at Test.lambda$main$0(Test.java:7)
at java.lang.Thread.run(Thread.java:748)
java.lang.NoClassDefFoundError: Could not initialize class XXXX.XX
at Test.lambda$main$1(Test.java:15)
at java.lang.Thread.run(Thread.java:748)
Gson2.8.6 版本报错 java.lang.NoSuchMethodError: com.google.gson.JsonParser.parseString (Ljava/lang/String;)
绪
最近在 Scala 的项目中尝试使用 Gson 来做 json 的数据解析;Scala 自带和 Jackson 使用都太过繁琐;
使用 Gson 在 scala 代码如下;唯一的就是需要解析完后需要调用 getAsXXX;嵌套对象需要重复执行这个方法;JsonParser 在 2.8.6 里面 new 方法放弃了。推荐用静态方法;2.8.5 里面,还是通过 new 来实例化 JsonParser;
val json = JsonParser.parseString(s)
val obj = json.getAsJsonObject
println(obj.get("@timestamp"))
但是在项目中,碰到一个错误。NoSuchMethodError。不知道如何下手了;本地跑可以,到集群就崩;错误如下:
java.lang.NoSuchMethodError: com.google.gson.JsonParser.parseString(Ljava/lang/String;)Lcom/google/gson/JsonElement #1077
解决方法
换个低版本的 2.8.5;正常不报错了、
val jsonParser = new JsonParser()
val jsonObj = jsonParser.parse(line).getAsJsonObject
关于Jackson注释JsonFormat $Value json java.lang.NoSuchMethodError和jackson注解解析json的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于ava.lang.NoSuchMethodError: scala.Predef$.ArrowAssoc(Ljava/lang/Object;)Ljava/lang/Object;、com.fasterxml.jackson.databind.jsonFormatVisitors.JsonValueFormat的实例源码、fastjson报NoSuchMethodError诡异、Gson2.8.6 版本报错 java.lang.NoSuchMethodError: com.google.gson.JsonParser.parseString (Ljava/lang/String;)等相关知识的信息别忘了在本站进行查找喔。
本文标签: