Reputation: 13299
So we decided to deploy our application no more as a war on the usual tomcat, but from an embedded jetty. My app uses context:property-placeholder
to resolve properties from a file. Now I'd need to pass some (or all) properties programatically before starting jetty. Is there a way that allows me to set some properties by code, before running jetty, instead of relying on the .properties file? For example as Servlet params?
Upvotes: 0
Views: 301
Reputation: 709
You can use ServletContextPropertyPlaceholderConfigurer
. This PropertyPlaceholderConfigurer extract the properties from the servlet context init params.
From Spring Javadocs:
Subclass of PropertyPlaceholderConfigurer that resolves placeholders as ServletContext init parameters (that is, web.xml context-param entries).
But this class is deprecated from Spring version 3.1.
From version 3.1 you don't need to use any special configuration because all Web Based servlet context use the class org.springframework.web.context.support.StandardServletEnvironment
that resolve properties from servlet context params by default.
Upvotes: 2