spring mssing 包 org.springframework.web
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12603723/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The mssing package org.springframework.web
提问by Winte Winte
I continue learning maven and try to understand why I get this error package "org.springframework.web.servlet does not exist" when org.springframework.web dependecy already have defined in pom.
我继续学习 maven 并试图理解为什么当 org.springframework.web 依赖项已经在 pom 中定义时我会收到这个错误包“org.springframework.web.servlet 不存在”。
<groupId>com.home.springtraining</groupId
<artifactId>SpringTrainingTemplate</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>SpringTrainingTemplate</name>
<url>http://maven.apache.org</url>
<properties>
<spring.version>3.1.1.RELEASE</spring.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
Could you tell me why this error occurs?
你能告诉我为什么会出现这个错误吗?
回答by axtavt
org.springframework.web.servletis a part of Spring MVC, it's located in org.springframework:spring-webmvcartifact:
org.springframework.web.servlet是 Spring MVC 的一部分,它位于org.springframework:spring-webmvc工件中:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
org.springframework:spring-webcontains common functionality for using Spring in web applications, it's not tied to Spring MVC.
org.springframework:spring-web包含在 Web 应用程序中使用 Spring 的通用功能,它与 Spring MVC 无关。
回答by Satya
add this dependency to your pom.xml
将此依赖项添加到您的 pom.xml
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>

