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ファイルが作成されず
パッケージの依存関係を解決できずにエラーが発生します。