Ne AS
Ne AS

Reputation: 1550

Application.properties for each environment

I want to create application.properties for each environment. By default, the existing one is application.properties when I try to add a new file having .properties as extension, the icon of the file is not the same as the application.properties. I get the icon of the Ressource bundle. This is how I create the new file: Right click on my ressources package -> New -> File

Then for the its name I put application_dev.properties.

How can I get a spring boot properties file instead of a Ressource bundle one?

Upvotes: 1

Views: 1531

Answers (2)

Gregg
Gregg

Reputation: 35904

That's not the convention. Resource bundles use underscores. You want to use dashes.

  • application-local.properties
  • application-dev.properties
  • application-staging.propertes

And then use -Dspring.profiles.active=dev flag to switch and/or @ActiveProfiles("dev") to trigger which profile is used.

Upvotes: 2

BrianC
BrianC

Reputation: 1822

Another option here is to just put the application.properties in the environment outside of the SpringBoot JAR. That way the environmental specific options are configured in the environment not in the build so you do not have to do different builds for each environment. It can be a big complexity and time saver.

Upvotes: 0

Related Questions