7

I want to launch my spring-boot application after a cf push with a custom profile named my_profile, but the app is always launched with the default one cloud profile. How can I specify the exact profile to load?

I already tried to add the environment variable in the manifest.yml like this:

env:
      SPRING_PROFILES_ACTIVE: my_profile 

But the application was load with both profiles (cloud & my_profile)

Do you have a solution to load juste my custom profile and not integrate the default one?

marherbi
  • 351
  • 4
  • 15

2 Answers2

9

This is coming from the Java buildpack and it's Spring Auto-reconifguration support.

The Spring Auto-reconfiguration Framework adds the cloud profile to any existing Spring profiles such as those defined in the SPRING_PROFILES_ACTIVE environment variable.

https://github.com/cloudfoundry/java-buildpack/blob/master/docs/framework-spring_auto_reconfiguration.md

To disable this behavior, you can disable the Spring Auto-reconfiguration support.

Set an env variable JBP_CONFIG_SPRING_AUTO_RECONFIGURATION to { enabled: false }.

Ex:

cf set-env my-cool-app JBP_CONFIG_SPRING_AUTO_RECONFIGURATION '{ enabled: false }'

Please note that this will also disable the cloud.* properties and automatic rewriting of bean to configure services.

https://github.com/cloudfoundry/java-buildpack-auto-reconfiguration#what-is-auto-reconfiguration

Daniel Mikusa
  • 13,716
  • 1
  • 22
  • 28
  • Daniel can you please look into this https://stackoverflow.com/questions/68163062/java-lang-illegalstateexception-pcf – Gen Jun 28 '21 at 13:06
2

You can also add this inside manifest.yaml as below:

env:
  SPRING_PROFILES_ACTIVE: my_profile
  JBP_CONFIG_SPRING_AUTO_RECONFIGURATION: '{ enabled: false }'
ramindroid
  • 105
  • 1
  • 8