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