AnnotationConfigRegistry找不到春天4
问题描述:
我有一个奇怪的行为,使用spring 4.1.1我得到这个错误。AnnotationConfigRegistry找不到春天4
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project newvalia-view: Compilation failure
[ERROR] /C:/Users/edu/IdeaProjects/newvalia/newvalia- view/src/main/java/com/newvalia/web/init/WebInitContext.java:[19,12] cannot access org.springframework.context.annotation.AnnotationConfigRegistry
[ERROR] class file for org.springframework.context.annotation.AnnotationConfigRegistry not found
而如果我降级到春天4.0.7它编译正确。 我使用简单的弹簧webmwc配置:
@Configuration
@ComponentScan(value = "com.newvalia.web")
@EnableWebMvc
public class WebMvcConfig extends WebMvcConfigurerAdapter {
}
public class WebInitContext implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext container) {
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
ctx.register(WebMvcConfig.class);
ctx.setServletContext(container);
Dynamic servlet = container.addServlet("dispatcher", new DispatcherServlet(ctx));
servlet.addMapping("/");
servlet.setLoadOnStartup(1);
}
这是一个新的预期的行为?
答
导入org.springframework.context
正确的jar在你的pom文件中,就是这样。
希望有所帮助。
你在导入org.springframework.context的jar文件吗? – 2014-10-05 09:17:49
是的,我只是在改变春天的版本。这就是全部 – duardito 2014-10-05 09:34:09
哦,我的天啊,我指着一个经过编码的弹簧上下文jar,而不是pom中的全局属性。 – duardito 2014-10-05 09:36:42