Spring boot-GradleIntelliJ Idea构建和Jenkins构建的结果不一样。
我花了很多时间通过jenkins部署spring boot应用程序。然而,我一直在失败 在我的本地环境中,执行gradleSpring boot-GradleIntelliJ Idea构建和Jenkins构建的结果不一样。,jenkins,spring-boot,intellij-idea,gradle,build.gradle,Jenkins,Spring Boot,Intellij Idea,Gradle,Build.gradle,我花了很多时间通过jenkins部署spring boot应用程序。然而,我一直在失败 在我的本地环境中,执行gradlebootRepackage命令,以Intellij Idea构建一个jar文件,运行jar文件(使用命令java-jar-Dspring.profile.active=user ABC.jar) 因此,我将此命令注册到Jenkins,并通过SSH上的发布发送jar,步骤如下 使用bootRepackage--stacktrace-x test--refresh depende
bootRepackage
命令,以Intellij Idea构建一个jar
文件,运行jar
文件(使用命令java-jar-Dspring.profile.active=user ABC.jar
)
因此,我将此命令注册到Jenkins,并通过SSH上的发布发送jar
,步骤如下
bootRepackage--stacktrace-x test--refresh dependencies调用gradle脚本
java-jar-Dspring.profile.active=user ABC.jar执行
buildscript {
ext {
springBootVersion = '1.5.1.RELEASE'
springBootStarterVersion = '1.5.6.RELEASE'
infinispanVersion = '8.2.6.Final'
coreVersion = '0.0.1-SNAPSHOT'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'war'
jar {
baseName = 'ABC'
manifest {
attributes('Main-Class': 'net.ion.ice.Ice2Application')
}
}
bootRepackage {
withJarTask jar
mainClass = 'net.ion.ice.Ice2Application'
}
war {
baseName = 'ABC'
version = "${coreVersion}"
enabled = false
manifest {
attributes('Main-Class': 'net.ion.ice.Ice2Application')
}
}
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
maven {
url 'http://my-repo.com/nexus/content/groups/public/'
name 'my-repo'
}
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web:${springBootStarterVersion}")
compile("org.springframework.boot:spring-boot-starter-tomcat:${springBootStarterVersion}")
compile("org.springframework.boot:spring-boot-starter-security:${springBootStarterVersion}")
compile('org.springframework.boot:spring-boot-configuration-processor')
compile('org.apache.commons:commons-lang3:3.5+')
compile('commons-net:commons-net:3.4+')
compile('commons-io:commons-io:2.5+')
compile('com.fasterxml.jackson.core:jackson-databind:2.8.6+')
compile('com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.8.6+')
// yml parser
compile ('com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.8.9')
compile('ch.qos.logback:logback-access:1.2.3')
compile('net.logstash.logback:logstash-logback-encoder:4.8+')
compile ("org.eclipse.persistence:javax.persistence:2.1.1")
compile("org.infinispan:infinispan-embedded:${infinispanVersion}")
compile("org.infinispan:infinispan-query:${infinispanVersion}")
compile('io.jsonwebtoken:jjwt:0.7.0')
compile("org.springframework:spring-jdbc")
compile("org.apache.commons:commons-dbcp2:2.1.1")
compile('com.oracle:ojdbc8:12.2.0.1') //oracle
compile('org.projectlombok:lombok:1.16.16')
runtime('org.springframework.boot:spring-boot-devtools')
testCompile("org.springframework.boot:spring-boot-starter-test:${springBootStarterVersion}")
testCompile("com.microsoft.sqlserver:mssql-jdbc:6.2.1.jre8")
}
我发现它与构建环境无关。这只是一个代码问题。有人再次用空值覆盖
Bean
不管怎样,谢谢你帮我。(特别是,@alexbt)我发现它与构建环境无关。这只是一个代码问题。有人再次用空值覆盖
Bean
不管怎样,谢谢你帮我。(特别是,@alexbt)这似乎是一个环境问题。当您在本地运行jar时,可能是指向服务器上找不到的本地资源?检查日志?比较两个jar,看看哪些文件是不同的(如果有的话)。比较环境变量。我看到您使用的是
spring.profile.active=user
,猜测服务器上找不到application user.properties
(在本地存在)?@alexbt事实上,这两个war文件看起来内容相同(大小相同)。我使用gradlebuild--refresh dependencies--stacktrace-x test
生成war文件。这个命令可能是错误的?另外,parallel
关键字会对这一点产生影响吗?(除了一个spring boot web应用程序,我没有什么要构建的)@alexbt upper one是build命令,我使用java-jar-Dspring.profile.active=user ABC.war
运行应用程序,我可以在日志中看到profilename。这似乎是环境问题。当您在本地运行jar时,可能是指向服务器上找不到的本地资源?检查日志?比较两个jar,看看哪些文件是不同的(如果有的话)。比较环境变量。我看到您使用的是spring.profile.active=user
,猜测服务器上找不到application user.properties
(在本地存在)?@alexbt事实上,这两个war文件看起来内容相同(大小相同)。我使用gradlebuild--refresh dependencies--stacktrace-x test
生成war文件。这个命令可能是错误的?另外,parallel
关键字会对这一点产生影响吗?(我没有什么要构建的,只有一个spring boot web应用程序)@alexbt-upper-one是build命令,我使用java-jar-Dspring.profile.active=user ABC.war
运行应用程序,我可以在日志中看到profilename。