gpt4 book ai didi

spring - 缺少的包org.springframework.web

转载 作者:行者123 更新时间:2023-12-04 13:52:41 26 4
gpt4 key购买 nike

我继续学习Maven,并尝试理解为什么在pom中已经定义了org.springframework.web依赖时,为什么得到此错误包“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>

您能告诉我为什么会发生此错误吗?

最佳答案

org.springframework.web.servlet是Spring MVC的一部分,位于org.springframework:spring-webmvc Artifact 中:

<dependency> 
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
org.springframework:spring-web包含在Web应用程序中使用Spring的常用功能,它与Spring MVC无关。

关于spring - 缺少的包org.springframework.web,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12603723/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com