我已经通过Intellij创建了spring项目,在通过SpringApplication.run()方法构建或启动项目之后,我无法看到我的web存档。在文档页上,我找到了三个应该遵守的条款。
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
来构建脚本,确保嵌入的servlet容器不会干扰部署war文件的servlet容器我的servlet初始化程序
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(RegTemplateApplication.class);
}
}
我的构建脚本
buildscript {
ext {
springBootVersion = '1.5.3.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'org.springframework.boot'
apply plugin: 'war'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
configurations {
providedRuntime
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.boot:spring-boot-starter-web')
runtime('com.h2database:h2')
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
发布于 2017-05-12 09:55:40
要组装war,您应该运行gradle assemble
默认情况下,此命令将从src/main/webapp
源创建war工件。还请检查源是否位于dir中,或者应该提供webAppDirName
属性。
请参阅plugin.html
发布于 2017-05-12 09:58:03
我试着用:
gradle clean build
并在此目录中找到web存档:
./build/libs/build.war
注意:您必须在您的机器上安装gradle。
https://stackoverflow.com/questions/43933903
复制相似问题