We've generated a basic Spring Boot application to test some features.
I've prepared it to be deployed on an embedded server and on Java EE servers (Tomcat 7 and JBoss EAP 6.2) without applying any changes.
I've included server.context-parameters.*
property on application.properties file.
If I deploy the application on an embedded server using java -jar
or mvn spring-boot:run
, it's working without problems. But, If I deploy the same application on Tomcat 7 or JBoss EAP 6.2, I'm not able to load the context-params correctly.
You could see all debugging information related with this Spring Boot issue here
Finally, I found the following solution thanks to Stéphane Nicoll
server.context-parameters.*
only works for embedded servers, so to configure context-parameters on Java EE server is necessary to include a @Bean
of type ServletContextInitializer
like the following:
@Bean
public ServletContextInitializer contextInitializer() {
return new ServletContextInitializer() {
@Override
public void onStartup(ServletContext servletContext)
throws ServletException {
servletContext.setInitParameter("dummy.type","on-context-parameters");
}
};
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With