【发布时间】:2014-08-27 19:03:17
【问题描述】:
我使用 Spring 工具套件创建了一个 Spring MVC Web 应用程序,我正在尝试创建这个类,但是当我执行 import 时出现此错误:
The import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer cannot be resolved
这是我要创建的类
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
public class WebApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
}
我知道将WebApplicationInitializer 放到一个类中可能会产生一些问题,但是当我尝试使用另一个名称时,我得到了同样的错误。
这是我的 pom.xml 文件
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework-version}</version>
<exclusions>
<!-- Exclude Commons Logging in favor of SLF4j -->
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework-version}</version>
</dependency>
我的春季版本是 3.1.1。RELEASE 我的库中已经有 webmvc,但在我的支持中。“类列表”该类不存在我喜欢那里有 7 个类,但不是那个。
----已编辑
我将我的 spring 版本更新为 4.0.6 RELEASE,它知道该类出现在我的类路径 org.springframework.web.servlet.support 中。""
【问题讨论】:
-
你的类路径中有那个类吗?
-
如何在 spring 工具套件中查看我的类路径?
-
查看构建路径,包含库。
-
不,我没有,我查看了 org.springframework.web.servlet.support,我有 7 个类,但我想要的类不存在
-
那你需要添加它。
标签: java spring spring-mvc import