Announcement Announcement Module
Collapse
No announcement yet.
SpringApplication and WebApplicationInitializer Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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.

    Code:
    @ComponentScan("base.package")
    @EnableAutoConfiguration
    public class RestApplication {
        public static void main(String[] args) {
            SpringApplication.run(RestApplication.class, 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 stackoverflow.com for our forums. If you're still having this issue please consider asking it again at http://stackoverflow.com using the #spring-boot tag. If you do post it there, please reply here with the link. Thanks!

    Comment

    Working...
    X