Search code examples
springjvmapache-cameljvm-arguments

Access JVM options in Spring's Application Context xml


Is there any way to access any -D option value (JVM Option) in Spring's applicationContext.xml?

I am accessing Apache Camel Context through Spring's applicationContest.xml and separate out my routes or camelContexts based -Denv="preprod".


Solution

  • If you have a property-placeholder configured you can access the system properties using ${env}.

    If you are using spring 3.0 or higher you can use the spring expression language support (Spel) - #{systemProperties.env}