即使在 POM 中定义了包 org.springframework.web.bind.annotation 也不存在 [英] package org.springframework.web.bind.annotation does not exist even though it's defined in POM
本文介绍了即使在 POM 中定义了包 org.springframework.web.bind.annotation 也不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我有这个代码
import org.springframework.web.bind.annotation.GetMapping;
而且我的 POM 文件中已经包含以下内容
And I already have the following in my POM file
<packaging>war</packaging>
<properties>
<spring.version>4.3.0.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</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-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
然而,当我构建它时,它最终抱怨包 org.springframework.web.bind.annotation 不存在
Yet when I built it ends up complaining package org.springframework.web.bind.annotation does not exist
为什么?我已经添加了 spring web 作为依赖项.我做错了什么?
Why? I already added spring web as a dependency. What am I doing wrong?
推荐答案
我遇到了类似的问题,我通过进入我的 pom.xml 文件并更改了 spring boot 依赖项的 artifactID 来解决它:
I had a similar issue, I fixed it by going into my pom.xml file and changing the artifactID for the spring boot dependency from:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
到
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
这篇关于即使在 POM 中定义了包 org.springframework.web.bind.annotation 也不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文