0

How do you get the active profile from a running spring boot application from the command-line?

I know about jcmd but I could not find anything that references the springboot properties.

Is there another way or am I missing something with jcmd?

WesAtWork
  • 65
  • 7

1 Answers1

0

If you own the application, i.e. you have access to the source code and permission to change it, you can enable the /env Actuator end-point which should give you the names of the active profiles. You can call this end-point from command line using cURL, for example.

Ref.: Retrieving the Entire Environment

Attila T
  • 577
  • 1
  • 4
  • 18
  • Yeah we already have that up and running. Sadly I can't use curl on the container and curling from outside isn't an option either. – WesAtWork Oct 11 '22 at 14:37
  • @WesselScholtz Monitoring and management can be made accessible via JMX as well. Ref.: [Monitoring and Management over JMX](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#actuator.jmx). Would that be a viable option for you? – Attila T Oct 11 '22 at 20:08
  • The JMX thing looks interesting! Turns out that `curl` wasn't available but `wget` was (for some reason). Poking it a bit I managed to get it to do what I wanted! Thanks for your help anyways @AttilaT – WesAtWork Oct 12 '22 at 14:15