close

[Solved] Including profiles in spring boot 2.4.0 version

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Including profiles in spring boot 2.4.0 version in java. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Including profiles in spring boot 2.4.0 version Error Occurs?

Today I get the following error Including profiles in spring boot 2.4.0 version in java.

How To Solve Including profiles in spring boot 2.4.0 version Error ?

  1. How To Solve Including profiles in spring boot 2.4.0 version Error ?

    To Solve Including profiles in spring boot 2.4.0 version Error You can use spring.config.import using classpath:
    spring.config.import=classpath:application-DEV.yml,classpath:application-auth.yml

  2. Including profiles in spring boot 2.4.0 version

    To Solve Including profiles in spring boot 2.4.0 version Error You can use spring.config.import using classpath:
    spring.config.import=classpath:application-DEV.yml,classpath:application-auth.yml

Solution 1

You can use spring.config.import using classpath:

spring.config.import=classpath:application-DEV.yml,classpath:application-auth.yml

Solution 2

Although we have an accepted answer above. But I would share my solution via multiple files. I’m having multiple config files in my project

./
application.yml
application-auth.yml
application-mockauth.yml
application-datasource.yml

The body of application-auth.yml or application-datasource.yml are the same as we’re implementing before spring boot 2.4. Minor adjustment will be located inside application.yml

spring:
  profiles:
    group:
      "dev": "datasource,mockauth"
      "prod": "datasource,auth"

Instead of spring.profiles.include, you will group related config with environment name (dev, prod…).

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read

Leave a Comment