【发布时间】:2018-12-21 05:59:54
【问题描述】:
我遇到了与 Gradle 4.8.1 建立战争的问题。这是 build.gradle:
buildscript {
ext {
springBootVersion = '2.0.3.RELEASE'
}
repositories {
jcenter()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
}
}
apply plugin: 'idea'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'org.springframework.boot'
apply plugin: 'war'
archivesBaseName = 'sample'
//war {
// archiveName = 'sample.war'
// group = 'my.group'
// version = '2.0.0-SNAPSHOT'
//}
sourceCompatibility = 1.8
repositories {
jcenter()
maven { url "${nexusUrl}/content/groups/public" }
}
dependencies {
// Spring
compile 'org.springframework.boot:spring-boot-starter-actuator'
compile 'org.springframework.boot:spring-boot-starter-data-jpa'
compile 'org.springframework.boot:spring-boot-starter-log4j2'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
compile 'org.springframework.boot:spring-boot-starter-web'
testCompile 'org.springframework.boot:spring-boot-starter-test'
// Lombok
compile "org.projectlombok:lombok:1.18.0"
// Data
compile ('org.postgresql:postgresql') {
exclude module: 'slf4j-simple'
}
// Http
compile "org.apache.httpcomponents:httpclient:4.5.5"
}
configurations {
all*.exclude module: 'spring-boot-starter-logging'
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: "${nexusUrl}/content/groups/public/") {
authentication(userName: nexusUsername, password: nexusPassword)
}
snapshotRepository(url: "${nexusUrl}/content/repositories/snapshots") {
authentication(userName: nexusUsername, password: nexusPassword)
}
pom.version = '2.0.0-SNAPSHOT'
pom.artifactId = 'sample'
pom.groupId = 'my.group'
}
}
}
我还尝试删除“maven”插件、archivesBaseName 和 uploadArchive 任务,同时取消注释战争任务,我得到了相同的结果。使用uploadArchive 时,战争可以很好地部署到nexus 服务器,并且我没有收到任何错误。将战争部署到 tomcat(在这两种情况下)时,tomcat 7 和 8 都没有抛出错误,并且我没有收到来自 catalina 或项目的日志,尽管战争任务中的 archiveName 没有正确重命名战争。我已经在其他两台机器/tomcat 实例上尝试过,结果相同。将其构建为胖 jar 或在 IntelliJ 中运行时,一切都按预期工作(包括日志记录)。
任何帮助或指导将不胜感激。
【问题讨论】:
标签: spring maven tomcat gradle war