Home onStartup method of WebApplicationInitializer never gets called
Reply: 0

onStartup method of WebApplicationInitializer never gets called

user1037 Published in June 18, 2018, 7:18 am

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;

public class MyWebApplicationInitializer implements WebApplicationInitializer {

    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.321376 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO