我对用Java 11来解决这个com.fasterxml.jackson.dataformat.xml.XmlMapper错误感到困惑。我只想使用杰克逊依赖项中的XmlMapper,这就是为什么将其排除在springboot之外,仍然无法解决它的依赖性。提供尽可能多的细节-
build.gradle
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
jaxb
fatJar
}
repositories {
mavenCentral()
}
dependencies {
implementation ('org.springframework.boot:spring-boot-starter-web') {
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core'
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-annotations'
}
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
compileOnly 'org.projectlombok:lombok:1.18.4'
annotationProcessor 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-xml', version: '2.12.2'
compile("com.newrelic.logging:logback:2.0")
implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.2.4'
jaxb (
'com.sun.xml.bind:jaxb-xjc:2.3.1',
'com.sun.xml.bind:jaxb-impl:2.3.1',
'org.glassfish.jaxb:jaxb-runtime:2.3.3'
)
}
依赖层次结构
+--- com.newrelic.logging:logback:2.0
+--- org.springframework.boot:spring-boot-starter-web -> 2.4.5
| +--- org.springframework.boot:spring-boot-starter:2.4.5
| | +--- org.springframework.boot:spring-boot:2.4.5
| | | +--- org.springframework:spring-core:5.3.6
| | | | \--- org.springframework:spring-jcl:5.3.6
| | | \--- org.springframework:spring-context:5.3.6
| | | +--- org.springframework:spring-aop:5.3.6
| | | | +--- org.springframework:spring-beans:5.3.6
| | | | | \--- org.springframework:spring-core:5.3.6 (*)
| | | | \--- org.springframework:spring-core:5.3.6 (*)
| | | +--- org.springframework:spring-beans:5.3.6 (*)
| | | +--- org.springframework:spring-core:5.3.6 (*)
| | | \--- org.springframework:spring-expression:5.3.6
| | | \--- org.springframework:spring-core:5.3.6 (*)
| | +--- org.springframework.boot:spring-boot-autoconfigure:2.4.5
| | | \--- org.springframework.boot:spring-boot:2.4.5 (*)
| | +--- org.springframework.boot:spring-boot-starter-logging:2.4.5
| | | +--- ch.qos.logback:logback-classic:1.2.3
| | | | +--- ch.qos.logback:logback-core:1.2.3
| | | | \--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
| | | +--- org.apache.logging.log4j:log4j-to-slf4j:2.13.3
| | | | +--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
| | | | \--- org.apache.logging.log4j:log4j-api:2.13.3
| | | \--- org.slf4j:jul-to-slf4j:1.7.30
| | | \--- org.slf4j:slf4j-api:1.7.30
| | +--- jakarta.annotation:jakarta.annotation-api:1.3.5
| | +--- org.springframework:spring-core:5.3.6 (*)
| | \--- org.yaml:snakeyaml:1.27
| +--- org.springframework.boot:spring-boot-starter-json:2.4.5
| | +--- org.springframework.boot:spring-boot-starter:2.4.5 (*)
| | +--- org.springframework:spring-web:5.3.6
| | | +--- org.springframework:spring-beans:5.3.6 (*)
| | | \--- org.springframework:spring-core:5.3.6 (*)
| | +--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.11.4
| | +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.11.4
| | \--- com.fasterxml.jackson.module:jackson-module-parameter-names:2.11.4
| +--- org.springframework.boot:spring-boot-starter-tomcat:2.4.5
| | +--- jakarta.annotation:jakarta.annotation-api:1.3.5
| | +--- org.apache.tomcat.embed:tomcat-embed-core:9.0.45
| | +--- org.glassfish:jakarta.el:3.0.3
| | \--- org.apache.tomcat.embed:tomcat-embed-websocket:9.0.45
| | \--- org.apache.tomcat.embed:tomcat-embed-core:9.0.45
| +--- org.springframework:spring-web:5.3.6 (*)
| \--- org.springframework:spring-webmvc:5.3.6
| +--- org.springframework:spring-aop:5.3.6 (*)
| +--- org.springframework:spring-beans:5.3.6 (*)
| +--- org.springframework:spring-context:5.3.6 (*)
| +--- org.springframework:spring-core:5.3.6 (*)
| +--- org.springframework:spring-expression:5.3.6 (*)
| \--- org.springframework:spring-web:5.3.6 (*)
+--- org.springframework.boot:spring-boot-starter-actuator -> 2.4.5
| +--- org.springframework.boot:spring-boot-starter:2.4.5 (*)
| +--- org.springframework.boot:spring-boot-actuator-autoconfigure:2.4.5
| | +--- org.springframework.boot:spring-boot-actuator:2.4.5
| | | \--- org.springframework.boot:spring-boot:2.4.5 (*)
| | +--- org.springframework.boot:spring-boot:2.4.5 (*)
| | \--- org.springframework.boot:spring-boot-autoconfigure:2.4.5 (*)
| \--- io.micrometer:micrometer-core:1.6.6
| \--- org.hdrhistogram:HdrHistogram:2.1.12
+--- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.12.2
| +--- com.fasterxml.jackson.core:jackson-core:2.12.2 -> 2.11.4
| +--- com.fasterxml.jackson.core:jackson-annotations:2.12.2 -> 2.11.4
| +--- com.fasterxml.jackson.core:jackson-databind:2.12.2 -> 2.11.4
| | +--- com.fasterxml.jackson.core:jackson-annotations:2.11.4
| | \--- com.fasterxml.jackson.core:jackson-core:2.11.4
| +--- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.12.2 -> 2.11.4
| | +--- com.fasterxml.jackson.core:jackson-annotations:2.11.4
| | +--- com.fasterxml.jackson.core:jackson-core:2.11.4
| | +--- com.fasterxml.jackson.core:jackson-databind:2.11.4 (*)
| | +--- jakarta.xml.bind:jakarta.xml.bind-api:2.3.2 -> 2.3.3
| | | \--- jakarta.activation:jakarta.activation-api:1.2.2
| | \--- jakarta.activation:jakarta.activation-api:1.2.1 -> 1.2.2
| +--- org.codehaus.woodstox:stax2-api:4.2.1
| +--- com.fasterxml.woodstox:woodstox-core:6.2.4
| | \--- org.codehaus.woodstox:stax2-api:4.2.1
| \--- com.fasterxml.jackson:jackson-bom:2.12.2
| +--- com.fasterxml.jackson.core:jackson-annotations:2.12.2 -> 2.11.4 (c)
| +--- com.fasterxml.jackson.core:jackson-core:2.12.2 -> 2.11.4 (c)
| +--- com.fasterxml.jackson.core:jackson-databind:2.12.2 -> 2.11.4 (c)
| +--- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.12.2 (c)
| +--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.12.2 -> 2.11.4 (c)
| +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.2 -> 2.11.4 (c)
| +--- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.12.2 -> 2.11.4 (c)
| \--- com.fasterxml.jackson.module:jackson-module-parameter-names:2.12.2 -> 2.11.4 (c)
+--- javax.xml.bind:jaxb-api:2.2.4
| +--- javax.xml.stream:stax-api:1.0-2
| \--- javax.activation:activation:1.1
\--- org.springframework.boot:spring-boot-starter-test -> 2.4.5
+--- org.springframework.boot:spring-boot-starter:2.4.5 (*)
+--- org.springframework.boot:spring-boot-test:2.4.5
| \--- org.springframework.boot:spring-boot:2.4.5 (*)
+--- org.springframework.boot:spring-boot-test-autoconfigure:2.4.5
| +--- org.springframework.boot:spring-boot:2.4.5 (*)
| +--- org.springframework.boot:spring-boot-test:2.4.5 (*)
| \--- org.springframework.boot:spring-boot-autoconfigure:2.4.5 (*)
+--- com.jayway.jsonpath:json-path:2.4.0
| +--- net.minidev:json-smart:2.3
| | \--- net.minidev:accessors-smart:1.2
| | \--- org.ow2.asm:asm:5.0.4
| \--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
+--- jakarta.xml.bind:jakarta.xml.bind-api:2.3.3 (*)
+--- org.assertj:assertj-core:3.18.1
+--- org.hamcrest:hamcrest:2.2
+--- org.junit.jupiter:junit-jupiter:5.7.1
| +--- org.junit:junit-bom:5.7.1
| | +--- org.junit.jupiter:junit-jupiter:5.7.1 (c)
| | +--- org.junit.jupiter:junit-jupiter-api:5.7.1 (c)
| | +--- org.junit.jupiter:junit-jupiter-params:5.7.1 (c)
| | \--- org.junit.platform:junit-platform-commons:1.7.1 (c)
| +--- org.junit.jupiter:junit-jupiter-api:5.7.1
| | +--- org.junit:junit-bom:5.7.1 (*)
| | +--- org.apiguardian:apiguardian-api:1.1.0
| | +--- org.opentest4j:opentest4j:1.2.0
| | \--- org.junit.platform:junit-platform-commons:1.7.1
| | +--- org.junit:junit-bom:5.7.1 (*)
| | \--- org.apiguardian:apiguardian-api:1.1.0
| \--- org.junit.jupiter:junit-jupiter-params:5.7.1
| +--- org.junit:junit-bom:5.7.1 (*)
| +--- org.apiguardian:apiguardian-api:1.1.0
| \--- org.junit.jupiter:junit-jupiter-api:5.7.1 (*)
+--- org.mockito:mockito-core:3.6.28
| +--- net.bytebuddy:byte-buddy:1.10.18 -> 1.10.22
| +--- net.bytebuddy:byte-buddy-agent:1.10.18 -> 1.10.22
| \--- org.objenesis:objenesis:3.1
+--- org.mockito:mockito-junit-jupiter:3.6.28
| \--- org.mockito:mockito-core:3.6.28 (*)
+--- org.skyscreamer:jsonassert:1.5.0
| \--- com.vaadin.external.google:android-json:0.0.20131108.vaadin1
+--- org.springframework:spring-core:5.3.6 (*)
+--- org.springframework:spring-test:5.3.6
| \--- org.springframework:spring-core:5.3.6 (*)
\--- org.xmlunit:xmlunit-core:2.7.0
testCompileOnly - Compile only dependencies for source set 'test'. (n)
No dependencies
testImplementation - Implementation only dependencies for source set 'test'. (n)
\--- org.springframework.boot:spring-boot-starter-test (n)
testRuntimeClasspath - Runtime classpath of source set 'test'.
+--- com.newrelic.logging:logback:2.0
| +--- com.fasterxml.jackson.core:jackson-core:2.11.1 -> 2.11.4
| +--- ch.qos.logback:logback-core:1.2.0 -> 1.2.3
| +--- ch.qos.logback:logback-classic:1.2.0 -> 1.2.3
| | +--- ch.qos.logback:logback-core:1.2.3
| | \--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
| \--- com.newrelic.agent.java:newrelic-api:5.6.0
+--- org.springframework.boot:spring-boot-starter-web -> 2.4.5
| +--- org.springframework.boot:spring-boot-starter:2.4.5
| | +--- org.springframework.boot:spring-boot:2.4.5
| | | +--- org.springframework:spring-core:5.3.6
| | | | \--- org.springframework:spring-jcl:5.3.6
| | | \--- org.springframework:spring-context:5.3.6
| | | +--- org.springframework:spring-aop:5.3.6
| | | | +--- org.springframework:spring-beans:5.3.6
| | | | | \--- org.springframework:spring-core:5.3.6 (*)
| | | | \--- org.springframework:spring-core:5.3.6 (*)
| | | +--- org.springframework:spring-beans:5.3.6 (*)
| | | +--- org.springframework:spring-core:5.3.6 (*)
| | | \--- org.springframework:spring-expression:5.3.6
| | | \--- org.springframework:spring-core:5.3.6 (*)
| | +--- org.springframework.boot:spring-boot-autoconfigure:2.4.5
| | | \--- org.springframework.boot:spring-boot:2.4.5 (*)
| | +--- org.springframework.boot:spring-boot-starter-logging:2.4.5
| | | +--- ch.qos.logback:logback-classic:1.2.3 (*)
| | | +--- org.apache.logging.log4j:log4j-to-slf4j:2.13.3
| | | | +--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
| | | | \--- org.apache.logging.log4j:log4j-api:2.13.3
| | | \--- org.slf4j:jul-to-slf4j:1.7.30
| | | \--- org.slf4j:slf4j-api:1.7.30
| | +--- jakarta.annotation:jakarta.annotation-api:1.3.5
| | +--- org.springframework:spring-core:5.3.6 (*)
| | \--- org.yaml:snakeyaml:1.27
| +--- org.springframework.boot:spring-boot-starter-json:2.4.5
| | +--- org.springframework.boot:spring-boot-starter:2.4.5 (*)
| | +--- org.springframework:spring-web:5.3.6
| | | +--- org.springframework:spring-beans:5.3.6 (*)
| | | \--- org.springframework:spring-core:5.3.6 (*)
| | +--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.11.4
| | +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.11.4
| | | +--- com.fasterxml.jackson.core:jackson-annotations:2.11.4
| | | +--- com.fasterxml.jackson.core:jackson-core:2.11.4
| | | \--- com.fasterxml.jackson.core:jackson-databind:2.11.4
| | | +--- com.fasterxml.jackson.core:jackson-annotations:2.11.4
| | | \--- com.fasterxml.jackson.core:jackson-core:2.11.4
| | \--- com.fasterxml.jackson.module:jackson-module-parameter-names:2.11.4
| +--- org.springframework.boot:spring-boot-starter-tomcat:2.4.5
| | +--- jakarta.annotation:jakarta.annotation-api:1.3.5
| | +--- org.apache.tomcat.embed:tomcat-embed-core:9.0.45
| | +--- org.glassfish:jakarta.el:3.0.3
| | \--- org.apache.tomcat.embed:tomcat-embed-websocket:9.0.45
| | \--- org.apache.tomcat.embed:tomcat-embed-core:9.0.45
| +--- org.springframework:spring-web:5.3.6 (*)
| \--- org.springframework:spring-webmvc:5.3.6
| +--- org.springframework:spring-aop:5.3.6 (*)
| +--- org.springframework:spring-beans:5.3.6 (*)
| +--- org.springframework:spring-context:5.3.6 (*)
| +--- org.springframework:spring-core:5.3.6 (*)
| +--- org.springframework:spring-expression:5.3.6 (*)
| \--- org.springframework:spring-web:5.3.6 (*)
+--- org.springframework.boot:spring-boot-starter-actuator -> 2.4.5
| +--- org.springframework.boot:spring-boot-starter:2.4.5 (*)
| +--- org.springframework.boot:spring-boot-actuator-autoconfigure:2.4.5
| | +--- com.fasterxml.jackson.core:jackson-databind:2.11.4 (*)
| | +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.11.4 (*)
| | +--- org.springframework.boot:spring-boot-actuator:2.4.5
| | | \--- org.springframework.boot:spring-boot:2.4.5 (*)
| | +--- org.springframework.boot:spring-boot:2.4.5 (*)
| | \--- org.springframework.boot:spring-boot-autoconfigure:2.4.5 (*)
| \--- io.micrometer:micrometer-core:1.6.6
| +--- org.hdrhistogram:HdrHistogram:2.1.12
| \--- org.latencyutils:LatencyUtils:2.0.3
+--- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.12.2
| +--- com.fasterxml.jackson.core:jackson-core:2.12.2 -> 2.11.4
| +--- com.fasterxml.jackson.core:jackson-annotations:2.12.2 -> 2.11.4
| +--- com.fasterxml.jackson.core:jackson-databind:2.12.2 -> 2.11.4 (*)
| +--- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.12.2 -> 2.11.4
| | +--- com.fasterxml.jackson.core:jackson-annotations:2.11.4
| | +--- com.fasterxml.jackson.core:jackson-core:2.11.4
| | +--- com.fasterxml.jackson.core:jackson-databind:2.11.4 (*)
| | +--- jakarta.xml.bind:jakarta.xml.bind-api:2.3.2 -> 2.3.3
| | | \--- jakarta.activation:jakarta.activation-api:1.2.2
| | \--- jakarta.activation:jakarta.activation-api:1.2.1 -> 1.2.2
| +--- org.codehaus.woodstox:stax2-api:4.2.1
| +--- com.fasterxml.woodstox:woodstox-core:6.2.4
| | \--- org.codehaus.woodstox:stax2-api:4.2.1
| \--- com.fasterxml.jackson:jackson-bom:2.12.2
| +--- com.fasterxml.jackson.core:jackson-annotations:2.12.2 -> 2.11.4 (c)
| +--- com.fasterxml.jackson.core:jackson-core:2.12.2 -> 2.11.4 (c)
| +--- com.fasterxml.jackson.core:jackson-databind:2.12.2 -> 2.11.4 (c)
| +--- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.12.2 (c)
| +--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.12.2 -> 2.11.4 (c)
| +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.2 -> 2.11.4 (c)
| +--- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.12.2 -> 2.11.4 (c)
| \--- com.fasterxml.jackson.module:jackson-module-parameter-names:2.12.2 -> 2.11.4 (c)
+--- javax.xml.bind:jaxb-api:2.2.4
| +--- javax.xml.stream:stax-api:1.0-2
| \--- javax.activation:activation:1.1
\--- org.springframework.boot:spring-boot-starter-test -> 2.4.5
+--- org.springframework.boot:spring-boot-starter:2.4.5 (*)
+--- org.springframework.boot:spring-boot-test:2.4.5
| \--- org.springframework.boot:spring-boot:2.4.5 (*)
+--- org.springframework.boot:spring-boot-test-autoconfigure:2.4.5
| +--- org.springframework.boot:spring-boot:2.4.5 (*)
| +--- org.springframework.boot:spring-boot-test:2.4.5 (*)
| \--- org.springframework.boot:spring-boot-autoconfigure:2.4.5 (*)
+--- com.jayway.jsonpath:json-path:2.4.0
| +--- net.minidev:json-smart:2.3
| | \--- net.minidev:accessors-smart:1.2
| | \--- org.ow2.asm:asm:5.0.4
| \--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
+--- jakarta.xml.bind:jakarta.xml.bind-api:2.3.3 (*)
+--- org.assertj:assertj-core:3.18.1
+--- org.hamcrest:hamcrest:2.2
+--- org.junit.jupiter:junit-jupiter:5.7.1
| +--- org.junit:junit-bom:5.7.1
| | +--- org.junit.jupiter:junit-jupiter:5.7.1 (c)
| | +--- org.junit.jupiter:junit-jupiter-api:5.7.1 (c)
| | +--- org.junit.jupiter:junit-jupiter-engine:5.7.1 (c)
| | +--- org.junit.jupiter:junit-jupiter-params:5.7.1 (c)
| | +--- org.junit.platform:junit-platform-commons:1.7.1 (c)
| | \--- org.junit.platform:junit-platform-engine:1.7.1 (c)
| +--- org.junit.jupiter:junit-jupiter-api:5.7.1
| | +--- org.junit:junit-bom:5.7.1 (*)
| | +--- org.apiguardian:apiguardian-api:1.1.0
| | +--- org.opentest4j:opentest4j:1.2.0
| | \--- org.junit.platform:junit-platform-commons:1.7.1
| | +--- org.junit:junit-bom:5.7.1 (*)
| | \--- org.apiguardian:apiguardian-api:1.1.0
| +--- org.junit.jupiter:junit-jupiter-params:5.7.1
| | +--- org.junit:junit-bom:5.7.1 (*)
| | +--- org.apiguardian:apiguardian-api:1.1.0
| | \--- org.junit.jupiter:junit-jupiter-api:5.7.1 (*)
| \--- org.junit.jupiter:junit-jupiter-engine:5.7.1
| +--- org.junit:junit-bom:5.7.1 (*)
| +--- org.apiguardian:apiguardian-api:1.1.0
| +--- org.junit.platform:junit-platform-engine:1.7.1
| | +--- org.junit:junit-bom:5.7.1 (*)
| | +--- org.apiguardian:apiguardian-api:1.1.0
| | +--- org.opentest4j:opentest4j:1.2.0
| | \--- org.junit.platform:junit-platform-commons:1.7.1 (*)
| \--- org.junit.jupiter:junit-jupiter-api:5.7.1 (*)
+--- org.mockito:mockito-core:3.6.28
| +--- net.bytebuddy:byte-buddy:1.10.18 -> 1.10.22
| +--- net.bytebuddy:byte-buddy-agent:1.10.18 -> 1.10.22
| \--- org.objenesis:objenesis:3.1
+--- org.mockito:mockito-junit-jupiter:3.6.28
| +--- org.mockito:mockito-core:3.6.28 (*)
| \--- org.junit.jupiter:junit-jupiter-api:5.4.2 -> 5.7.1 (*)
+--- org.skyscreamer:jsonassert:1.5.0
| \--- com.vaadin.external.google:android-json:0.0.20131108.vaadin1
+--- org.springframework:spring-core:5.3.6 (*)
+--- org.springframework:spring-test:5.3.6
| \--- org.springframework:spring-core:5.3.6 (*)
\--- org.xmlunit:xmlunit-core:2.7.0
运行引导应用程序-时出错
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
com.fasterxml.jackson.dataformat.xml.XmlMapper.<init>(XmlMapper.java:175)
The following method did not exist:
'com.fasterxml.jackson.databind.cfg.MutableCoercionConfig com.fasterxml.jackson.dataformat.xml.XmlMapper.coercionConfigDefaults()'
The method's class, com.fasterxml.jackson.dataformat.xml.XmlMapper, is available from the following locations:
jar:file:/C:/Users/user1/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.dataformat/jackson-dataformat-xml/2.12.2/dac1d21b5fe602d492273d35eb28918a91fc5412/jackson-dataformat-xml-2.12.2.jar!/com/fasterxml/jackson/dataformat/xml/XmlMapper.class
The class hierarchy was loaded from the following locations:
com.fasterxml.jackson.dataformat.xml.XmlMapper: file:/C:/Users/user1/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.dataformat/jackson-dataformat-xml/2.12.2/dac1d21b5fe602d492273d35eb28918a91fc5412/jackson-dataformat-xml-2.12.2.jar
com.fasterxml.jackson.databind.ObjectMapper: file:/C:/Users/user1/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-databind/2.11.4/5d9f3d441f99d721b957e3497f0a6465c764fad4/jackson-databind-2.11.4.jar
com.fasterxml.jackson.core.ObjectCodec: file:/C:/Users/user1/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.11.4/593f7b18bab07a76767f181e2a2336135ce82cc4/jackson-core-2.11.4.jar
com.fasterxml.jackson.core.TreeCodec: file:/C:/Users/user1/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.11.4/593f7b18bab07a76767f181e2a2336135ce82cc4/jackson-core-2.11.4.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of com.fasterxml.jackson.dataformat.xml.XmlMapper
发布于 2021-05-22 21:00:58
您是否明确需要xml的2.12.2版本?
问题
jackson-dataformat-xml:2.12.2与jackson依赖项2.11.4不兼容。Spring覆盖在依赖项块或dependencyManagement中未指定的其他方式的Jackson依赖项。
溶液
如果不需要2.12.2,那么只需将jackson-dataformat-xml定义如下:
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-xml'
那么解决方案将是
com.fasterxml.jackson.dataformat:jackson-dataformat-xml -> 2.11.4
这将与所有其他杰克逊组件兼容,您将不再获得此异常。始终尝试检查Jackson的依赖项,并确保所有依赖项都对齐。
例如,如果运行“gradlew依赖项”并获得以下结果,则会发现这是错误的:
+--- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.12.2
| +--- com.fasterxml.jackson.core:jackson-core:2.12.2 -> 2.11.4
杰克逊的版本没有正确地对齐。通过管理Gradle依赖关系,您必须确保对它们进行对齐,这意味着升级或降级它们。
如果您确实需要显式2.12.2,那么还应该升级包含更新版本的Spring版本。
您可以通过以下方式指定Spring的版本:
dependencyManagement {
imports {
mavenBom 'org.springframework.boot:spring-boot-dependencies:2.5.0'
}
}
发布于 2021-09-17 18:20:49
当您只需要XMLMapper时,为什么要调用整个数据格式库?
我找到了使用Spring的解决办法,因为我只需要XMLMapper:
在声明中获取对消息转换器的引用:
private final MappingJackson2XmlHttpMessageConverter msgConverter;
稍后只需从它的父级引用它: ObjectMapper
ObjectMapper xmlMapper = xmlConverter.getObjectMapper();
这样,您就不应该进入所描述的依赖问题。
所以,您只需要导入com.fasterxml.jackson.databind.ObjectMapper
https://stackoverflow.com/questions/67647991
复制相似问题