Property ‘spring.profiles.active’ imported from location ‘class path resource [application-dev.yml]’ is invalid

We Are Going To Discuss About Property ‘spring.profiles.active’ imported from location ‘class path resource [application-dev.yml]’ is invalid. So lets Start this Java Article.

Property ‘spring.profiles.active’ imported from location ‘class path resource [application-dev.yml]’ is invalid

  1. Property 'spring.profiles.active' imported from location 'class path resource [application-dev.yml]' is invalid

    Spring Boot 2.4 has improved the way that application.properties and application.yml files are processed.

  2. 'spring.profiles.active' imported from location 'class path resource [application-dev.yml]' is invalid

    Spring Boot 2.4 has improved the way that application.properties and application.yml files are processed.

Solution 1

Spring Boot 2.4 has improved the way that application.properties and application.yml files are processed.

See here for details: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-Config-Data-Migration-Guide

Long story short: If you have for example an application-local.yml and inside you defined

spring:
profiles:
    active: local 

then just remove this entry in the yaml file.

Original Author Of This Content

Solution 2

No need to mention spring.profiles.active property if file name is application-dev.yml ( spring boot new version )

Original Author Of This Content

Solution 3

In your application-dev.yml, you declare :

spring:
    application:
        name: mail-service
    profiles:
        active: local 

2 solutions :

  1. rename application-dev.yml to application-local.yml and use local profile
  2. change spring.profiles.active to dev in application-dev.yml

Original Author Of This Content

Solution 4

Since version 2.4 (Spring Boot 2.4):

Profiles can no longer be activated from profile specific documents.

https://spring.io/blog/2020/08/14/config-file-processing-in-spring-boot-2-4

One way forward could be to use spring.profiles.group.*

  1. From application-dev.yml remove: profiles: active: local

  2. rename application-dev.yml -> application-dev123.yml

  3. In application.properties define group “dev”: spring.profiles.group.dev=local,dev123

Group named “dev” now is replacement for previous profile named “dev”.

Original Author Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment