我有以下结构。
我正在通过复制粘贴从众多来源构建build.gradle。
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.bmuschko:gradle-tomcat-plugin:2.2.2'
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'war'
apply plugin: 'com.bmuschko.tomcat'
webAppDirName = 'WebContent'
repositories {
jcenter()
mavenCentral()
}
sourceSets {
main {
// where does the Java source code live?
java {
srcDir 'src'
}
// where do classpath resources like *.properties files live?
resources {
srcDir 'src/main/resources'
}
}
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
dependencies {
testCompile("junit:junit")
compile fileTree(dir: 'WebContent/WEB-INF/lib', include: ['*.jar'])
String tomcatVersion = '7.0.52'
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}"
tomcat "org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"
tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
tomcat {
contextPath = '/'
}
当我运行gradle tomcatRun
时,我看到以下输出
02:49:58.819 [安静] [com.bmuschko.gradle.tomcat.embedded.BaseTomcatServerImpl $ AfterStartEventLifecycleListener] Tomcat Server 02:49:58.820 [QUIET] [com.bmuschko.gradle.tomcat.embedded.BaseTomcatServerImpl $ AfterStartEventLifecycleListener] 服务器正在http://localhost:8080
运行构建75%> :tomcatRun
但是当我连接到http://localhost:8080时,我看到404错误或空白页面。