gradle-tomcat-demo
- a gradle-tomcat-demo without
web.xml
Github : https://github.com/LT-java-demos/gradle-tomcat-demo
Gradle Tomcat plugin
build.gradle配置
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'com.bmuschko.tomcat'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.bmuschko:gradle-tomcat-plugin:2.2.5'
}
}
repositories {
mavenCentral()
}dependencies {
def tomcatVersion = '7.0.59'
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
"org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}",
"org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}"
}
運(yùn)行Tomcat
$ gradle tomcatRun
運(yùn)行結(jié)果
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:tomcatRun
Started Tomcat Server
The Server is running at http://localhost:8080/gradle-tomcat-demo
> Building 75% > :tomcatRun
訪問:http://localhost:8080/gradle-tomcat-demo可以看到 index.jsp
頁面的 Hello World
回到終端 Ctrl + c
/ command + c
停止 Tomcat