Thursday, 13 June 2019

Exclude jar from war in a Spring Boot gradle project

Spring Boot version : 2.1.4.RELEASE

If you would like to use jar only for compilation purpose and exclude the jar at run time or not part of the war then you can do as follows

In the gradle.build properties file use "compileOnly files" Option

dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("io.springfox:springfox-swagger2:2.9.2")
    implementation("io.springfox:springfox-swagger-ui:2.9.2")
compileOnly files('libs/<some>-api.jar')
}

As mentioned in the above dependencies , <some>-api.jar placed under libs folder will be used only for compile time and it will be not part of the war


No comments:

Post a Comment