import org.gradle.plugins.ide.eclipse.model.Facet
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'eclipse'
apply plugin: 'eclipse-wtp'
sourceCompatibility = 1.7 // 设置 JDK 版本
webAppDirName = 'WebContent' // 设置 WebApp 根目录
sourceSets.main.java.srcDir 'src/main/java' // 设置 Java 源码所在目录
// 设置 maven 库地址
repositories {
mavenCentral() // 中央库
}
// 设置依赖
dependencies {
providedCompile 'javax.servlet:servlet-api:2.5' // 编译期
providedRuntime 'javax.servlet:jstl:1.2' // 运行时
compile 'org.springframework:spring-context:4.3.8.RELEASE'
compile group: 'org.springframework', name: 'spring-core', version: '4.3.8.RELEASE'
compile group: 'org.springframework', name: 'spring-beans', version: '4.3.8.RELEASE'
compile group: 'org.springframework', name: 'spring-context', version: '4.3.8.RELEASE'
compile group: 'org.springframework', name: 'spring-context-support', version: '4.3.8.RELEASE'
compile group: 'org.springframework', name: 'spring-web', version: '4.3.8.RELEASE'
compile group: 'org.springframework', name: 'spring-webmvc', version: '4.3.8.RELEASE'
compile group: 'org.springframework', name: 'spring-aop', version: '4.3.8.RELEASE'
compile group: 'org.springframework', name: 'spring-tx', version: '4.3.8.RELEASE'
compile group: 'org.springframework', name: 'spring-jdbc', version: '4.3.8.RELEASE'
compile group: 'org.springframework', name: 'spring-test', version: '4.3.8.RELEASE'
compile group: 'org.springframework.data', name: 'spring-data-jpa', version: '1.11.3.RELEASE'
}
// 设置 Project Facets
eclipse {
wtp {
facet {
facet name: 'jst.web', type: Facet.FacetType.fixed
facet name: 'wst.jsdt.web', type: Facet.FacetType.fixed
facet name: 'jst.java', type: Facet.FacetType.fixed
facet name: 'jst.web', version: '3.1'
facet name: 'jst.java', version: '1.7'
facet name: 'wst.jsdt.web', version: '1.0'
}
}
}
设置spring 版本
dependencies { // 设置依赖 def springVersion='4.3.8.RELEASE' dependencies { providedCompile 'javax.servlet:servlet-api:2.5' // 编译期 providedRuntime 'javax.servlet:jstl:1.2' // 运行时 compile 'org.springframework:spring-context:$springVersion' compile group: 'org.springframework', name: 'spring-core', version:'$springVersion' compile( 'org.springframework:spring-beans: $springVersion', 'org.springframework:spring-context-support:$springVersion', 'org.springframework:spring-web:$springVersion', 'org.springframework:spring-webmvc:$springVersion', 'org.springframework:spring-aop:$springVersion', 'org.springframework:spring-tx:$springVersion', 'org.springframework:spring-jdbc:$springVersion', 'org.springframework:spring-test:$springVersion', 'org.springframework:spring-context:$springVersion' ) compile group: 'org.springframework.data', name: 'spring-data-jpa', version: '1.11.3.RELEASE' } testCompile group: 'junit', name: 'junit', version: '4.11' testCompile group: 'junit', name: 'junit', version: '4.12' }