Java 9とgradleでSpringBootを使用しようとしています。単純なコードを実行できません。以下のエラーが発生します:-
Information:Java: Errors occurred while compiling module 'Java9Gradle_main'
Information:javac 9-ea was used to compile Java sources
Information:6/9/2017 10:40 PM - Compilation completed with 65 errors and 0 warnings in 15s 200ms
Error:Java: module reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module spring.boot.starter.web reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module spring.boot.starter.web reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module spring.boot.autoconfigure reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module spring.boot.autoconfigure reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module spring.boot.starter.logging reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module spring.boot.starter.logging reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module spring.core reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module spring.core reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module snakeyaml reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module snakeyaml reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module spring.boot.starter.Tomcat reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module spring.boot.starter.Tomcat reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module hibernate.validator reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module hibernate.validator reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module jackson.databind reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module jackson.databind reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module spring.web reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module spring.web reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module spring.webmvc reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module spring.webmvc reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module spring.context reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module spring.context reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module logback.classic reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module logback.classic reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module jcl.over.slf4j reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module jcl.over.slf4j reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module jul.to.slf4j reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module jul.to.slf4j reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module log4j.over.slf4j reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module log4j.over.slf4j reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module commons.logging reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module commons.logging reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module Tomcat.embed.core reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module Tomcat.embed.core reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module Tomcat.embed.el reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module Tomcat.embed.el reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module Tomcat.embed.websocket reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module Tomcat.embed.websocket reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module validation.api reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module validation.api reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module jboss.logging reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module jboss.logging reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module classmate reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module classmate reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module jackson.annotations reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module jackson.annotations reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module jackson.core reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module jackson.core reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module spring.aop reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module spring.aop reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module spring.beans reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module spring.beans reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module spring.expression reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module spring.expression reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module logback.core reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module logback.core reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module slf4j.api reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module slf4j.api reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module spring.boot.starter reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module spring.boot.starter reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
Error:Java: module spring.boot reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
Error:Java: module spring.boot reads package org.Apache.commons.logging.impl from both jcl.over.slf4j and commons.logging
D:\project\Java9Gradle\src\main\Java\module-info.Java
Error:(1, 1) Java: module Java9Gradle.main reads package org.Apache.commons.logging from both jcl.over.slf4j and commons.logging
私の依存関係ファイルとmodule-info.Javaファイルは非常に単純です。
module Java9Gradle.main {
requires spring.boot;
}
group 'Java9Gradle'
version '1.0-SNAPSHOT'
apply plugin: 'Java'
sourceCompatibility = 1.9
repositories {
mavenCentral()
}
dependencies {
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter
compile group: 'org.springframework.boot', name: 'spring-boot-starter', version: '1.5.3.RELEASE'
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.5.3.RELEASE'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
誰か助けてもらえますか?
ありがとう、
アマール
推移的な依存関係を除外すると、それが機能し、module-info.Javaも調整されました!!!
compile("org.springframework.boot:spring-boot-starter:1.5.3.RELEASE") {
exclude group: 'commons-logging', module: 'commons-logging'
}
compile("org.springframework.boot:spring-boot-starter-web:1.5.3.RELEASE"){
exclude group: 'commons-logging', module: 'commons-logging'
}
ジグソースペック によると
非干渉— Javaコンパイラ、仮想マシン、およびランタイムシステムは、同じ名前のパッケージを含むモジュールが互いに干渉しないようにする必要があります。2つの異なるモジュールに次のパッケージが含まれる場合同じ名前の場合、各モジュールの観点から、そのパッケージ内のすべてのタイプとメンバーはそのモジュールによってのみ定義されます。1つのモジュール内のそのパッケージ内のコードは、そのパッケージ内のパッケージプライベートタイプまたはメンバーにアクセスできないようにする必要があります。他のモジュールで。
これは、@ Andy here による回答では、split packagesと呼ばれています。そのための解決策は、これらのパッケージを分割解除し、モジュールに含まれているパッケージがjcl.over.slf4j
およびcommons.logging
は1つのモジュールのみを介してアクセスされます。
両方の依存関係を分析できますspring-boot-starter:1.5.3.RELEASE
およびspring-boot-starter-web:1.5.3.RELEASE
2つのモジュールのいずれかがプロジェクトに含まれていることを確認します。