charlesw
charlesw

Reputation: 91

Eclipse: no active profile set, falling back to default profiles: default

In application.properties, I specified

spring.profiles.active=dev

which should have picked application-dev.properties as the profile to activate.

However, when I Run As Java Application in Eclipse, I got the following message.

No active profile set, falling back to default profiles: default.

My best guess is this has something to do with Eclipse. Any comments?

Edit: I have tried Maven Update Project, followed by mvn clean install -U, also tried restarting Eclipse and cleaning the project. None of these worked...

Upvotes: 8

Views: 61778

Answers (2)

Atiksha
Atiksha

Reputation: 637

I was getting the same Problem.

After adding the below dependency in the pom.xml file, the application starts running.

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

Upvotes: 15

Ousama
Ousama

Reputation: 2810

Each enterprise application has many environments, like: dev, stage, prod.

Every environment requires a setting that is specific to them. For example, the database settings for dev env are not the same for prod env.

To create multiple environments in spring we should create a properties file for each one.

enter image description here

NB: No matter what type of file you use .properties or .yml, it will work

The application.yml will remain as a master properties file, but if we override any key in the profile-specific file, the latter will gain precedence.

In the normal Spring way, you can use a spring.profiles.active property to specify which profiles are active. You can specify the property in any of the usual ways, for example you could include it in your application.yml:

enter image description here

You should specify the profiles to enable on the command line, if you you need to use multiple profiles make sure to separate them with a comma :

$ mvn spring-boot:run -Dspring-boot.run.profiles=dev

Upvotes: 4

Related Questions