升级jdk 8到11版本后,更新model mapper plugin到2.3.9,仍然面临model mapper Exception

问题描述 投票:0回答:1
Exception Message: org.modelmapper.MappingException: ModelMapper mapping errors:1) Error mapping
  at org.modelmapper.internal.Errors.throwMappingExceptionIfErrorsExist(Errors.java:380)
  at org.modelmapper.internal.MappingEngineImpl.map(MappingEngineImpl.java:81)
  at org.modelmapper.ModelMapper.mapInternal(ModelMapper.java:573)
  at org.modelmapper.ModelMapper.map(ModelMapper.java:406)
  at rest.translator.impl.MongoDbDocumentTranslatorImpl.toResponse(MongoDbDocumentTranslatorImpl.java:214)
  at rest.translator.impl.MongoDbDocumentTranslatorImpl.translate(MongoDbDocumentTranslatorImpl.java:200)
  at rest.translator.impl.UserInformationTranslatorImpl.translate(UserInformationTranslatorImpl.java:38)
  at rest.controller.UserController.lambda$getAll$1(UserController.java:106)
  at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
  at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654)
  at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)...

我尝试更新模型映射器插件。它不起作用。

在本地,

getAll
端点似乎在工作。
在环境服务器级别,因模型映射器异常而失败。

这些是以下依赖项:

dependencies {
    compile 'org.springframework.boot:spring-boot-starter-actuator'
    compile 'org.springframework.boot:spring-boot-starter-data-mongodb'
    compile 'org.springframework.boot:spring-boot-starter-security'
    compile 'org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:2.1.0.M4'
    compile 'org.springframework.boot:spring-boot-starter-log4j2'
    compile 'org.springframework.security:spring-security-oauth2-resource-server'
    compile 'org.springframework.security:spring-security-oauth2-jose'
    compile 'org.springframework.security:spring-security-config'
    compile 'org.springframework.retry:spring-retry'
    compile 'org.springframework.boot:spring-boot-starter-cache'
    compile 'org.springframework.boot:spring-boot-starter-data-redis'
    compile('org.springframework.boot:spring-boot-starter-web') {
        exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
    }
    compile 'io.micrometer:micrometer-registry-prometheus'

    compile 'com.nimbusds:oauth2-oidc-sdk:7.1.1'

    compile 'io.springfox:springfox-swagger2:2.9.2'
    compile 'io.springfox:springfox-swagger-ui:2.9.2'
    compile 'io.springfox:springfox-bean-validators:2.9.2'
    compile "gradle.plugin.com.palantir.gradle.docker:gradle-docker:0.22.1"
    compile "gradle.plugin.com.github.sherter.google-java-format:google-java-format-gradle-plugin:0.8"
    compile 'org.apache.commons:commons-lang3:3.0'
    compile 'commons-io:commons-io:2.6'
    compile 'org.aspectj:aspectjweaver'
    compile 'org.modelmapper:modelmapper:2.3.9'
    compile 'com.amazonaws:aws-java-sdk-s3:1.11.797'
    compile 'com.amazonaws:aws-java-sdk-core:1.11.797'
    compile 'org.assertj:assertj-core:3.6.2'
    runtime 'org.springframework.boot:spring-boot-starter-tomcat'
    testCompile 'org.springframework.boot:spring-boot-starter-test'
    testCompile 'org.springframework.security:spring-security-test'
    testCompile 'org.springframework.restdocs:spring-restdocs-mockmvc'
    testCompile 'de.bwaldvogel:mongo-java-server:1.16.0'
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
    testCompile group: 'io.findify', name: 's3mock_2.12', version: '0.2.6'
    compile 'io.cucumber:cucumber-java:4.5.3'
    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-mail', version: '2.4.2'
    compileOnly "org.springframework.boot:spring-boot-configuration-processor"
    // jdk 11 migration dependencies
    implementation "javax.xml.bind:jaxb-api:2.3.1"
    implementation "com.sun.xml.bind:jaxb-core:2.3.0.1"
    implementation "com.sun.xml.bind:jaxb-impl:2.3.1"
    implementation "com.sun.activation:javax.activation:1.2.0"
    implementation("javax.annotation:javax.annotation-api:1.3.2")
    compile group: 'org.ow2.asm', name: 'asm', version: '7.1'
    testCompile("javax.xml.ws:jaxws-api:2.3.1")
    implementation 'org.springframework.boot:spring-boot-test'
    implementation 'org.springframework.boot:spring-boot-test-autoconfigure'
    // end of jdk 11 migration dependencies
}

modelmapper 2.4.0 也导致相同的异常。

可能的解决方法是什么!!?

java gradle upgrade java-11 modelmapper
1个回答
0
投票

错误已通过升级修复 id 'org.springframework.boot' 版本 '2.2.4.RELEASE' 到 id 'org.springframework.boot' 版本 '2.2.11.RELEASE' .

导致更新 spring.data.mongodb.core,它修复了由 spring.data.mongodb.core 模型映射引起的模型映射错误。

© www.soinside.com 2019 - 2024. All rights reserved.