Good day. Trying to build a Spring MVC + Spring boot + Security project, pops up at startup:

org.springframework.beans.factory.BeanCreationException: There has been an error in the definition of an error that has been defined in the classroom resource path: ua / kiev / izodrom / egorov / configuration / AppConfig.class]: nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.multipart.commons.CommonsMultiplusResolver]: Factory method 'multipartResolver' threw exception; nested exception is java.lang.NoClassDefFoundError: org / apache / commons / fileupload / FileItemFactory

@Bean public UrlBasedViewResolver setupViewResolver() { UrlBasedViewResolver resolver = new UrlBasedViewResolver(); resolver.setPrefix("/WEB-INF/"); resolver.setSuffix(".jsp"); resolver.setViewClass(JstlView.class); return resolver; } @Bean public CommonsMultipartResolver multipartResolver() { return new CommonsMultipartResolver(); 

WEB:

 public class WebInitializer implements WebApplicationInitializer { @Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); ctx.register(AppConfig.class); ctx.register(SecurityConfig.class); servletContext.addListener(new ContextLoaderListener(ctx)); ctx.setServletContext(servletContext); ServletRegistration.Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx)); servlet.addMapping("/"); servlet.setLoadOnStartup(1); } } 
  • Bring the whole system, suddenly there is something there :) If it is in open source, then give a link to github. - Slava Semushin pm

1 answer 1

NoClassDefFoundError: org / apache / commons / fileupload / FileItemFactory

It looks like some problems with the lack of commons-fileupload or its incorrect version.

See also:

  • <dependency> <groupId> commons-fileupload </ groupId> <artifactId> commons-fileupload </ artifactId> <version> 1.3.2 </ version> </ dependency> <dependency> <groupId> commons-io </ groupId> <artifactId> commons-io </ artifactId> <version> 2.5 </ version> </ dependency> I started the problem with this) - Nikolay Egorov
  • Show the output of the mvn dependency:tree | grep commons mvn dependency:tree | grep commons and jar tvf target/you-app.jar | grep commons jar tvf target/you-app.jar | grep commons - Slava Semushin
  • [ERROR] No plugin found for prefix, org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C: \ Users \ Nikol \. m2 \ repository), central ( repo.maven.apache.org/maven2)] - Nikolay Egorov
  • package: [ERROR] Failed to execute the project on my project: ua.kiev.izodrom.egoov: my: jar: 0.0.1-SNAPSHOT: Could not find artifact : $ {el-impl.version} in central ( repo.maven.apache.org/maven2 ) - Nikolay Egorov
  • dependency ! = dependecy - Slava Semushin