【问题标题】:eclipse ResolutionException: Modules A and B export package P to module Ceclipse ResolutionException:模块 A 和 B 将包 P 导出到模块 C
【发布时间】:2020-10-15 08:09:31
【问题描述】:

我尝试将我的 java8 spring 项目迁移到 java11。现在,当我尝试从 Eclipse 运行它时,出现以下异常:

Error occurred during initialization of boot layer
java.lang.module.ResolutionException: Modules java.activation and jakarta.activation export package javax.activation to module spring.boot.starter.web

Referenced Libraries 下我只找到了导出包 javax.activation 的 jakarta.activation-api-1.2.2.jar。另一个模块 java.activation 我不知道它来自哪里。从名称来看,它应该在 JavaSE-11/JDK 内?我检查了条目 JRE 系统库,但在那里我没有看到那个包。

现在,古玩是 Gradle 6.5,我可以使用“gradlew bootRun”运行项目,它执行得很好。但是在 Eclipse 中,它会因错误而失败。

所以在 Eclipse 中,我只是尝试通过右键单击从构建路径中删除来删除 Jakarta.activation。尝试从 javax.activation 导入任何东西然后给我“导入无法解决”,到目前为止还不错。但是运行仍然会出现上述 ResolutionException 的问题。

所以要解决这个问题:

  • 导出 javax.activation 包的其他源代码在哪里?我如何找到它?
  • 如何防止 Eclipse 在运行时拥有这两个模块?
  • 我可以排除 gradle 中的模块,以便项目在运行“gradlew eclipse”后像往常一样工作吗?

感谢您的帮助!我花了几个小时搜索,到目前为止没有找到任何有用的东西。

build.gradle 如下所示:


plugins {
    id 'org.springframework.boot' version '2.2.5.RELEASE'
    id 'io.spring.dependency-management' version '1.0.8.RELEASE'
    id 'java'
    id 'eclipse'
}

group = 'example'
version = '0.3.0'
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11

repositories {
    mavenCentral()
}

configurations.all {
    // fix multiple slf4j dependencies are present
    exclude group: 'org.slf4j', module: 'slf4j-log4j12'
    //TODO: 1st approach to fix ResolutionException
    //exclude group: 'jakarta.activation', module: 'jakarta.activation-api'
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf:2.3.1.RELEASE'
    implementation ('org.springframework.boot:spring-boot-starter-web:2.3.1.RELEASE') {
        //TODO: 2nd approach to fix ResolutionException
        exclude group: 'jakarta.activation', module: 'jakarta.activation-api'
    }
    implementation 'org.springframework.boot:spring-boot-starter-security:2.3.1.RELEASE'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.3.1.RELEASE'
    implementation 'org.springframework.boot:spring-boot-starter-actuator:2.3.1.RELEASE'
    implementation 'mysql:mysql-connector-java:5.1.46'
    implementation 'com.querydsl:querydsl-jpa:4.1.4'
    implementation 'com.querydsl:querydsl-apt:4.1.4:jpa'
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'org.flywaydb:flyway-core:5.2.4'
    compileOnly 'org.springframework.boot:spring-boot-devtools:2.3.1.RELEASE'

    // https://mvnrepository.com/artifact/org.apache.odftoolkit/simple-odf
    implementation 'org.apache.odftoolkit:simple-odf:0.8.2-incubating'
    // https://mvnrepository.com/artifact/org.apache.commons/commons-text
    implementation 'org.apache.commons:commons-text:1.1'
    // https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
    implementation 'org.apache.commons:commons-lang3:3.7'
    // https://mvnrepository.com/artifact/org.apache.commons/commons-csv
    implementation 'org.apache.commons:commons-csv:1.5'
    // https://mvnrepository.com/artifact/org.apache.commons/commons-collections4/4.3
    implementation 'org.apache.commons:commons-collections4:4.3'

    implementation 'javax.validation:validation-api:2.0.0.Final'
    // Dependencies that are no longer in java11
    // implementation 'javax.xml.bind:jaxb-api:2.3.0'
    // implementation 'com.sun.xml.bind:jaxb-core:2.3.0'
    // implementation 'com.sun.xml.bind:jaxb-impl:2.3.0'

    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.2'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.5.2'
    testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.5.2'

}

eclipse {
    classpath {
        downloadJavadoc = true
        downloadSources = true
    }
}

我找到但到目前为止对我没有帮助的其他链接:

【问题讨论】:

    标签: eclipse spring-boot gradle java-9 gradle-eclipse


    【解决方案1】:

    好的,我在尝试创建示例来重现问题时找到了部分答案。

    首先我尝试清理项目以确保在 eclipse 中没有缓存任何不好的内容:

    gradlew clean eclipse
    

    问题还是出现了。

    现在我已经完成了工作并删除了所有构建文件、.project、.classpath 并重新运行gradlew eclipse,在添加新的运行配置时,项目现在可以正常启动了。 所以可能要怪运行配置的缓存。

    也许这个或与同一问题有关的其他帖子的交叉链接仍然可以帮助某人。

    【讨论】:

      猜你喜欢
      • 2018-02-26
      • 1970-01-01
      • 1970-01-01
      • 2017-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多