Home onStartup method of WebApplicationInitializer never gets called
Reply: 0

onStartup method of WebApplicationInitializer never gets called

ivish
1#
ivish Published in 2018-02-12 15:52:38Z

I have a Grails application. I am trying to set an active Spring profile by using the onStartup method of WebApplicationInitializer. I have annotated this Java class with @Configuration but onStartup method never gets invoked.

package my.package;

@Configuration
public class MyWebApplicationInitializer implements WebApplicationInitializer {

    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        servletContext.setInitParameter("spring.profiles.active", "test");
    }
}

In Config.groovy I have added,

grails.spring.bean.packages = ['my.package']

I also tried adding following code in resources.groovy

xmlns context: "http://www.springframework.org/schema/context"
context."component-scan" "base-package": "my.package"

But whatever code changes I try onStartup method never gets called.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.291876 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO