1
私はジェンキンを介してスプリングブートアプリケーションを展開するのに多くの時間を費やします。しかし、私は失敗し続けている。私の地元でSpringブート - グラデルIntellij IdeaビルドとJenkinsビルド結果は同じではありません。
、のIntelliJアイデアでjar
ファイルを構築するためにGradleのbootRepackage
コマンドを実行し、(コマンドjava -jar -Dspring.profile.active=user ABC.jar
付き)jar
ファイルを実行するためにOKです
だから私はジェンキンスに、このコマンドを登録してPublish Over SSH
経由jar
を送ります以下の手順に従います。
- 問題はautowired豆のいくつかは、私の地元では問題を持たないヌルなっている
java -jar -Dspring.profile.active=user ABC.jar
で実行
bootRepackage --stacktrace -x test --refresh-dependencies
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")
}
これは環境問題のようです。 jarをローカルで実行すると、おそらくサーバー上に見つからないローカルリソースを指しているでしょうか?ログを確認しますか? jarファイルと、異なるファイル(存在する場合)を比較します。環境変数を比較する。 'spring.profile.active = user'を使うと、' application-user.properties'がサーバー上に見つかりませんでした(ローカルに存在している間)? – alexbt
@alexbt実際には、2つの戦争ファイルは同じ内容(サイズは同じ)を持つように見えます。私は 'gradle build -refresh-dependencies --stacktrace -x test'でwarファイルを作っています。このコマンドは間違っていますか?また、 'parallel'キーワードはこれに影響を及ぼしますか? (私は何もビルドする必要はありませんが、ちょうど1つのスプリングブートWebアプリケーション) –
@alexbt上の1つはビルドコマンドです。java -jar -Dspring.profile.active = user ABC.war'でアプリケーションを実行しました。ログ。 –