1
我與this one有完全相同的問題。 不幸的是,他並沒有找到最終的一次性修復解決方案。Eclipse Spring Boot構建路徑包含重複項
每次創建新項目或使用gradle刷新依賴關係時,我都會得到包含重複條目錯誤的構建路徑(maven工作正常,但不是gradle)。
我必須在構建後每次手動刪除額外的jre系統庫。我認爲這個問題可能是由gradle設置造成的。因爲在我手動修復問題之後,如果我刷新gradle依賴關係,它會再次提升。
這裏是默認的sts build.gradle模板。
buildscript {
ext {
springBootVersion = '1.3.6.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'spring-boot'
apply plugin: 'war'
war {
baseName = 'demo'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
configurations {
providedRuntime
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-jdbc')
compile('org.springframework.boot:spring-boot-starter-web')
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.restdocs:spring-restdocs-mockmvc')
}
eclipse {
classpath {
containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
}
}
可以從.classpath文件看,有2個相同classpathentry爲jreSE-1.8
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="output" path="bin"/>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry kind="src" path="src/test/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry sourcepath="C:/Users/leo.zhou/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter-jdbc/1.3.6.RELEASE/8b780842222e055a165198d9f8198d3ff0da7f05/spring-boot-starter-jdbc-1.3.6.RELEASE-sources.jar" kind="lib" path="C:/Users/leo.zhou/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter-jdbc/1.3.6.RELEASE/6a1bd13afbae1dcd7207dfd6f8fd94b549fa32e5/spring-boot-starter-jdbc-1.3.6.RELEASE.jar">
<attributes>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry> .....
請任何幫助,將不勝感激。
謝謝,我試過你的建議。但沒有任何變化,問題仍然存在 – newbie
嘗試gradle clean refresh - 依賴關係 –
我剛發現我沒有啓用依賴管理。啓用它之後,問題就解決了。你知道爲什麼會發生這種情況? – newbie