LoginSignup
6
6

More than 5 years have passed since last update.

SpringBoot 2.0 マルチ・プロジェクトのビルド

Posted at

Spring Bootのバージョン 2 で 依存関係のあるプロジェクトを指定してビルドする場合、
Jarファイルを作るのか?実行可能Jarファイルを作るのか?を指定する必要があります。

以下は、batchプロジェクトをビルドするために、shareプロジェクトのビルドも必要な場合の例。

build.gradle
buildscript {
    ext {
        springBootVersion = '2.0.1.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

//途中省略

project(':batch'){
    archivesBaseName = 'batch'
    ext.mainClass = 'xxx.xxx.xxx.SampleApplication'

    dependencies {
        compile project(':share') //依存関係のあるプロジェクトを指定
    }
}

project(':share'){
    archivesBaseName = 'share'

    bootJar {
        enabled = false //実行可能Jarを作成しない
    }

    jar {
        enabled = true //Jarを作成する
    }
}

上記のjarの設定を記述しないと、ビルドした時にJarファイルが作成されず
パッケージの依存関係を解決できずにエラーが発生します。

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6