Maven 包org.springframework.stereotype不存在
我在运行mvn安装时收到包org.springframework.stereotype错误。 即使在.m2文件夹中也有这个包 显示这行代码时出错:Maven 包org.springframework.stereotype不存在,maven,Maven,我在运行mvn安装时收到包org.springframework.stereotype错误。 即使在.m2文件夹中也有这个包 显示这行代码时出错: import org.springframework.stereotype.Service; 依赖项包括: <springVersion>4.1.1.RELEASE</springVersion> <dependency> <groupId>org.springframework<
import org.springframework.stereotype.Service;
依赖项包括:
<springVersion>4.1.1.RELEASE</springVersion>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${springVersion}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${springVersion}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${springVersion}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${springVersion}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${springVersion}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${springVersion}</version>
</dependency>
所有依赖项都应该在
<dependencies>
...
</dependencies>
...
。。。或者您的代码将继续抛出该错误。在java 8和spring 4.x上运行独立java程序时,我遇到了类似的问题 出于某种原因,我在项目的引用JAR中没有看到spring上下文。maven应该自动引用它,但我没有看到这种情况发生 解决方案:我在pom.xml中手动添加了spring上下文依赖项,我的错误得到了修复
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.2.5.RELEASE</version>
</dependency>
org.springframework
spring上下文
4.2.5.1发布
我需要将scope标记改为“compile”而不是“runtime”,错误消失了
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
<scope>compile</scope>
org.springframework
弹簧芯
${spring.version}
编译
有时错误就在IDE中
尝试构建或清理您的项目以解决问题。是否可以再包含一点错误消息?类
org.springframework.stereotype.Service
包含在您正确定义的spring上下文依赖项中。如果没有更多信息,很难进一步提供帮助。请参阅我的更新。完整的错误消息。我不知道我还能包括什么谢谢,这帮助我修复了遗留代码中的构建错误。为我解决了它!谢谢
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
<scope>compile</scope>