2017-08-26 7 views
1

私はジェンキンを介してスプリングブートアプリケーションを展開するのに多くの時間を費やします。しかし、私は失敗し続けている。私の地元でSpringブート - グラデルIntellij IdeaビルドとJenkinsビルド結果は同じではありません。

、のIntelliJアイデアでjarファイルを構築するためにGradleのbootRepackageコマンドを実行し、(コマンドjava -jar -Dspring.profile.active=user ABC.jar付き)jarファイルを実行するためにOKです

だから私はジェンキンスに、このコマンドを登録してPublish Over SSH経由jarを送ります以下の手順に従います。

  1. 問題はautowired豆のいくつかは、私の地元では問題を持たないヌルなっているjava -jar -Dspring.profile.active=user ABC.jar

で実行

  • サーバーにbootRepackage --stacktrace -x test --refresh-dependencies
  • 送信jarファイルでGradleのスクリプトを呼び出します。私のbuild gradleスクリプトを見て、私にいくつかのアドバイスをお願いします。

    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") 
    } 
    
  • +0

    これは環境問題のようです。 jarをローカルで実行すると、おそらくサーバー上に見つからないローカルリソースを指しているでしょうか?ログを確認しますか? jarファイルと、異なるファイル(存在する場合)を比較します。環境変数を比較する。 'spring.profile.active = user'を使うと、' application-user.properties'がサーバー上に見つかりませんでした(ローカルに存在している間)? – alexbt

    +0

    @alexbt実際には、2つの戦争ファイルは同じ内容(サイズは同じ)を持つように見えます。私は 'gradle build -refresh-dependencies --stacktrace -x test'でwarファイルを作っています。このコマンドは間違っていますか?また、 'parallel'キーワードはこれに影響を及ぼしますか? (私は何もビルドする必要はありませんが、ちょうど1つのスプリングブートWebアプリケーション) –

    +0

    @alexbt上の1つはビルドコマンドです。java -jar -Dspring.profile.active = user ABC.war'でアプリケーションを実行しました。ログ。 –

    答えて

    0

    ビルド環境では問題がないことがわかりました。それは単なるコードの問題でした。ヌル値でもう一度Beanをオーバーライドします。

    とにかく、私を助けてくれてありがとう。 (特に@alexbt)

    関連する問題