1

in an included library unfortunately the following is done:

@Bean
public WebMvcConfigurer webMvcConfigurerAdapter() {
   return new WebMvcConfigurer() {
      public void addViewControllers(ViewControllerRegistry registry) {
          registry.addViewController("/notFound").setViewName("forward:/index.html");
          ...
      }
   }
}

How and where can I remove this in my application afterwards? I would like to create a separate error page for it. For other errors except 404 the error page works.

Many greetings

Edit:

@Configuration
@Primary
public class SpringMvcConfiguration {

    @Bean
    @Primary
    public WebMvcConfigurer mywebMvcConfigurerAdapter() {
        return new WebMvcConfigurer() {
            public void addViewControllers(ViewControllerRegistry registry) {
                registry.addViewController("/login").setViewName("login");
                registry.addViewController("/error").setViewName("error");
                registry.addViewController("/notFound").setViewName("notFound");
                registry.addViewController("/").setViewName("forward:/index.html");
            }
        };
    }
}

That not work, it fowarded always to index.html

Burner
  • 981
  • 19
  • 41
  • You could create your own WebMvcConfigurer bean, mark it as primary and only put whatever you need in it. You could even have it extend the one from the library if there are parts of it you want to keep. – Deltharis Oct 26 '22 at 11:40
  • See my edit. this not work. What do I wrong? – Burner Oct 26 '22 at 12:15
  • Try like so: [exclude bean from config](https://stackoverflow.com/q/18992880/592355)? (Discarding `WebMvcConfigurer` from "lib") – xerx593 Oct 26 '22 at 12:50

0 Answers0