Maven 已经成功加载依赖,但是依然报错的解决方案

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/qq262593421/article/details/100186665

                     Maven 已经成功加载依赖,但是依然报错的解决方案

先看pom.xml文件

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.gxwz</groupId>
  <artifactId>lottery3</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>

	<build>
		<finalName>lottery</finalName>
	</build>
	<properties>
		<spring.version>5.1.5.RELEASE</spring.version>
	</properties>

	<dependencies>
		<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
		<dependency>
		    <groupId>org.springframework</groupId>
		    <artifactId>spring-webmvc</artifactId>
		    <version>${spring.version}</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/com.hynnet/jxl -->
		<dependency>
			<groupId>com.hynnet</groupId>
			<artifactId>jxl</artifactId>
			<version>2.6.12.1</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
		<dependency>
		    <groupId>javax.servlet</groupId>
		    <artifactId>javax.servlet-api</artifactId>
		    <version>3.1.0</version>
		    <scope>provided</scope>
		</dependency>
		<!-- https://mvnrepository.com/artifact/taglibs/standard -->
		<dependency>
		    <groupId>taglibs</groupId>
		    <artifactId>standard</artifactId>
		    <version>1.1.2</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
		<dependency>
		    <groupId>javax.servlet</groupId>
		    <artifactId>jstl</artifactId>
		    <version>1.2</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml-schemas -->
		<dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi-ooxml</artifactId>
			<version>3.14</version>
		</dependency>
		
	</dependencies>

</project>

再看项目截图:

根据截图可以看到,项目已经成功加载了依赖的所有jar包了,

但是问题来了,pom.xml文件报错,显示jar包没找到。

根据测试发现,一添加org.apache.poi 的这个jar包pom.xml就会有报错。

		<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml-schemas -->
		<dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi-ooxml</artifactId>
			<version>3.14</version>
		</dependency>

经过了半天的折腾才发现是Maven在后台执行管理jar包时出现了很多xxx.jar.lastUpdated文件。

 

解决方案:

在项目的Libraries-Maven Dependencies 下找到搞事情的Maven依赖包poi-xxx.ar,

鼠标右键找到该jar包在本地仓库中的具体位置

然后再把xxx.jar.lastUpdated后缀的文件全部干掉

更新Maven项目 右键项目-Maven-Update Project

 

更新之后报错全部消失,大功告成!

喜欢的小伙伴记得点个赞!!!

如果帮助到你记得也点个赞!!!

猜你喜欢

转载自blog.csdn.net/qq262593421/article/details/100186665