1.build.gradle
apply plugin: "war" buildscript { repositories { jcenter() } dependencies { classpath 'org.akhikhl.gretty:gretty:1.2.4' } } apply plugin: 'org.akhikhl.gretty' group = "org.exam" version = "1.0" ext { jvmVersion="1.8" springVersion = "4.2.1.RELEASE" sl4jVersion="1.7.7" } repositories { mavenCentral() } [compileJava, compileTestJava, javadoc]*.options*.encoding = "UTF-8" configurations { all*.exclude module: 'commons-logging' } dependencies { compile("org.slf4j:jcl-over-slf4j:$sl4jVersion") compile("org.slf4j:slf4j-log4j12:$sl4jVersion") compile("org.springframework:spring-webmvc:$springVersion") providedCompile("javax.servlet:javax.servlet-api:3.1.0") compile("commons-fileupload:commons-fileupload:1.3.1") compile("com.fasterxml.jackson.core:jackson-databind:2.3.1") compile("org.apache.taglibs:taglibs-standard-impl:1.2.1") testCompile("org.springframework:spring-test:$springVersion") testCompile("junit:junit:4.12") } /* 解决设置版本不起作用问题 */ tasks.withType(JavaCompile) { sourceCompatibility = jvmVersion targetCompatibility = jvmVersion } gretty { port = 8080 contextPath ="/${project.name}" servletContainer = 'jetty9' }
源码:http://download.csdn.net/detail/xiejx618/7701173