Announcement Announcement Module
No announcement yet.
SpringApplication and WebApplicationInitializer Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • SpringApplication and WebApplicationInitializer

    I have a Spring MVC REST application up and running using a WebApplicationInitializer to set the CORS response headers like Access-Control-Allow-Origin and so on. This works as expected when I deploy the WAR to Jetty (using Gradle), but when packing the application using Spring Boot's SpringApplication with an embedded Jetty or Tomcat, the headers do not appear in the response.

    public class RestApplication {
        public static void main(String[] args) {
  , args);
    Judging by the Spring Boot API, there is a mechanism to add Spring ApplicationContexts, but not one to include a specific WebApplicationInitializer, as web applications seem to be automatically configured using @EnableAutoConfiguration.

    Is my approach wrong?

  • #2
    We are currently in the process of moving to for our forums. If you're still having this issue please consider asking it again at using the #spring-boot tag. If you do post it there, please reply here with the link. Thanks!