SpringBoot 2.0 multi-project build

When building with a dependent project in Spring Boot version 2 Do you want to create a Jar file? Do you want to create an executable Jar file? Must be specified.

The following is an example when you also need to build the share project in order to build the batch project.

build.gradle


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

//Omitted on the way

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

	dependencies {
		compile project(':share') //Specify a project with a dependency
    }
}

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

	bootJar {
		enabled = false //Do not create executable Jar
	}

	jar {
		enabled = true //Create a Jar
	}
}

If you do not describe the above jar settings, the Jar file will not be created when building The package dependency cannot be resolved and an error occurs.

Recommended Posts

SpringBoot 2.0 multi-project build
multi-project docker build using jib
Eclipse --Springboot