Приложение на Spring-MVC + Tomcat (без Spring-Boot)
Есть структура проекта:
Итак, когда я пытаюсь развернуть войну влокальный кот, есть сообщение об ошибке
Причина: java.lang.NoClassDefFoundError: org / aspectj / lang / annotation / Around в org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory. (ReflectiveAspectJAdvisorFactory.java: 77) в org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.initBeanFactory (AnnotationAwareAspectJAutoProxyCreator.java:78) в org.springframework.AjorFact.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods (AbstractAutowireCapableBeanFactory.java:1648) в org.springframework.beans.factory.support.ngframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean (AbstractAutowireCapableBeanFactory.java:555) ... еще 56 причин: java.lang.ClassNotFoundException: org.aspectno.cat.WebappClassLoaderBase.loadClass (WebappClassLoaderBase.java:1291) в org.apache.catalina.loader.WebappClassLoaderBase.loadClass (WebappClassLoaderBase.java:1119) ... еще 62
package init;
@Configuration
@EnableWebMvc
@ComponentScan("com")
public class WebAppInitalizer implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
rootContext.register(
WebConfig.class);
FilterRegistration charEncodingfilterReg = servletContext.addFilter("CharacterEncodingFilter", CharacterEncodingFilter.class);
charEncodingfilterReg.setInitParameter("encoding", "UTF-8");
charEncodingfilterReg.setInitParameter("forceEncoding", "true");
charEncodingfilterReg.addMappingForUrlPatterns(null, false, "/*");
servletContext.addListener(new ContextLoaderListener(rootContext));
ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(rootContext));
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/*");
}
}
Webf
@Configuration
@ComponentScan(basePackages = {"com"})
@EnableWebMvc
@EnableAspectJAutoProxy(proxyTargetClass = true)
public class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void configureDefaultServletHandling(
DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.add(new MappingJackson2HttpMessageConverter());
converters.add(new StringHttpMessageConverter());
}
@Bean
public RequestMappingHandlerMapping requestMappingHandlerMapping() {
RequestMappingHandlerMapping mhm = new RequestMappingHandlerMapping();
//suffix parser is off for urls like .../search/timeKey.key:some_key
mhm.setUseSuffixPatternMatch(false);
return mhm;
}
}
и контроллер:
@RestController
public class GreetingController {
@RequestMapping(value = "/greeting", method = RequestMethod.GET)
public String greeting() {
return "greeting";
}
}
applicationContext.xml и web.xml пусты.Итак, ошибка возникает при попытке зарегистрировать WebConfig в WebAppInitializer.