Reputation: 1407
I'm having the exact same question with this one. unfortunately he didn't find the ultimate one time fix solution either.
I will get the build path contains duplicate entry error each time when creating new project or refresh dependencies with gradle (maven works fine but gradle not).
I have to manually remove the extra jre system lib each time after the build. I think this problem might be caused by gradle setup. since after I manually fix the problem, it will raise again if I refresh the gradle dependencies.
here is the default sts build.gradle templete.
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'
}
}
you can see from the .classpath file, there are 2 same classpathentry for 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> .....
please any help will be appreciated.
Upvotes: 1
Views: 2255
Reputation: 2526
try adding following to buildscript's dependencies
classpath("io.spring.gradle:dependency-management-plugin:0.5.2.RELEASE")
and
apply plugin: 'io.spring.dependency-management'
and
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
at the end of the build.gradle file.
Upvotes: 1