pixel
pixel

Reputation: 26513

Bind Spring Boot application name to rootProject.name from Gradle?

I would like to set the application name in Spring Boot to the value from rootProject.name. Is there a way to do that?

Upvotes: 4

Views: 1461

Answers (1)

Chin Huang
Chin Huang

Reputation: 13860

Spring Boot reads the application name from the configuration property spring.application.name. Gradle can generate a configuration file containing that property.

Put in the src/main/resources/application.properties file:

spring.application.name=${rootProject.name}

Add the Gradle task:

processResources {
  filesMatching("application.properties") {
    expand project.properties
  }
}

Upvotes: 5

Related Questions