Jim*_*Jim 0 spring tomcat war gradle spring-boot
我一直在关注 spring 提供的教程,似乎无法理解为什么我的 .war 文件是空的。点击这里查看/下载代码。最终目标是下载此文件,构建一个 .war 文件,然后将其部署到我的 tomcat 服务器。我已将以下内容添加到 build.gradle
应用插件:“战争”
但这只会生成包含零类文件的战争。
构建.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle
plugin:1.5.3.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'war'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
jar {
baseName = 'gs-spring-boot'
version = '0.1.0'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
// tag::actuator[]
compile("org.springframework.boot:spring-boot-starter-actuator")
// end::actuator[]
// tag::tests[]
testCompile("org.springframework.boot:spring-boot-starter-test")
// end::tests[]
}
Run Code Online (Sandbox Code Playgroud)
对于教程代码,你需要做两件事:
用于打包spring-boot ref 的war 插件:
apply plugin: 'war'
war {
baseName = 'gs-spring-boot'
version = '0.1.0'
}
Run Code Online (Sandbox Code Playgroud)创建一个可部署的战争文件spring-boot ref:
@SpringBootApplication
public class Application extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
Run Code Online (Sandbox Code Playgroud)并且还指定提供的 tomcat 依赖项:
dependencies {
// …
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
// …
}
Run Code Online (Sandbox Code Playgroud)
这是我的提交参考和结果:
归档时间: |
|
查看次数: |
2030 次 |
最近记录: |