我第一次使用Gradle和Spring。我决定创建一个实际构建一个WAR存档的项目,我正在使用Gradle Jetty插件。如果我运行jettyRun或jettyRunWar任务,在浏览器中我只看到一个目录列表,而不是我的实际应用程序。
例如,jettyRunWar任务产生如下所示的目录:
META-INF/
WEB-INF/
dist/dist/目录包含我的静态文件。
也许是因为我第一次使用Gradle和Spring,所以我缺少了一些基本的东西。
我试图测试我的应用程序,同时对我的静态文件进行更改,而不重新启动应用程序。这是我的build.gradle文件。
buildscript {
repositories {
maven { url "http://repo.spring.io/libs-snapshot" }
mavenLocal()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:0.5.0.M6"
}
}
apply plugin: "java"
apply plugin: "idea"
apply plugin: "spring-boot"
apply plugin: "war"
war {
baseName = "mis-support-client"
version = "1.0.0-SNAPSHOT"
includes = ["dist/**"]
}
repositories {
mavenCentral()
maven { url "http://repo.spring.io/libs-snapshot" }
}
dependencies {
testCompile "junit:junit:4.11"
compile ("org.springframework.boot:spring-boot-starter-web:0.5.0.M7") {
exclude module: "spring-boot-starter-tomcat"
}
compile "org.springframework.boot:spring-boot-starter-jetty:0.5.0.M7"
compile "org.springframework.boot:spring-boot-starter-security:0.5.0.M7"
compile "org.springframework.boot:spring-boot-starter-websocket:0.5.0.M7"
compile "javax.inject:javax.inject:1"
compile "org.codehaus.jackson:jackson-mapper-asl:1.9.12"
compile "org.apache.httpcomponents:httpclient:4.3.1"
compile "commons-io:commons-io:2.4"
}
task wrapper (type: Wrapper) {
gradleVersion = "1.8"
}发布于 2014-01-09 19:42:50
你试过./gradlew bootRun了吗?普通的Spring项目嵌入了服务器,以便于使用:)
此任务需要gradle插件:
apply plugin: 'spring-boot'特性
直接嵌入Tomcat或Jetty (不需要部署WAR文件)
任务
Execution tasks
---------------
bootRun - Run the executable JAR/WARhttps://stackoverflow.com/questions/21029571
复制相似问题