Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

We are trying to upgrade Spring boot app from 1.5.9 to 2.2.7. We use the following Servlet Registrations in the app:

@Bean
public ServletRegistrationBean dispatcherServletRegistration() {
    ServletRegistrationBean registration = new ServletRegistrationBean(new DispatcherServlet());
    Map<String, String> params = new HashMap<String, String>();
    params.put("org.atmosphere.servlet", "org.springframework.web.servlet.DispatcherServlet");
    params.put("contextClass", "org.springframework.web.context.support.AnnotationConfigWebApplicationContext");
    registration.setInitParameters(params);
    return registration;
}


@Bean
public ServletRegistrationBean configureJerseyForRESTfulWebService() {
    ServletRegistrationBean registration = new ServletRegistrationBean(new ServletContainer(), "/service/*");
    registration.addInitParameter(ServletProperties.JAXRS_APPLICATION_CLASS, JerseyConfig.class.getName());
    registration.addInitParameter("com.sun.jersey.api.json.POJOMappingFeature", "true");
    return registration;
}


@Bean
public FilterRegistrationBean securityFilterRegistration() {
    FilterRegistrationBean registration = new FilterRegistrationBean();
    registration.setFilter(new SecurityFilter());
    registration.addUrlPatterns("/*");
    registration.setName("SecurityFilter");
    registration.setOrder(1);
    return registration;
}

After the upgrade, we are getting the following errors during startup and service unable to run:

Parameter 0 of method errorPageCustomizer in org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration required a bean of type 'org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPath' that could not be found.



The following candidates were found but could not be injected:
    - Bean method 'dispatcherServletRegistration' in 'DispatcherServletAutoConfiguration.DispatcherServletRegistrationConfiguration' not loaded because DispatcherServlet Registration found servlet registration bean dispatcherServletRegistration

Action:

Consider revisiting the entries above or defining a bean of type 'org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPath' in your configuration.

Any hint how to resolve theses errors/issues. If possible please share any code example, thanks


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
359 views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...