Maven依赖的JAR文件未更新或在Eclipse中出现错误。

11 浏览
0 Comments

Maven依赖的JAR文件未更新或在Eclipse中出现错误。

我是Maven开发的初学者,需要你们的帮助来解决这个问题。我发现在.m2\repository\org\springframework\spring-context\3.1.0.RELEASE目录下没有可用的jar文件,只有下面这些文件可用:

spring-context-3.1.0.RELEASE.jar.lastUpdated

spring-context-3.1.0.RELEASE.pom.lastUpdated

[图片](https://i.stack.imgur.com/MHfwj.png)

此外,在pom.xml中我还遇到以下错误:

构建过程中发生了错误。

在项目“cim”上运行Maven项目构建器时发生错误。

无法计算构建计划:插件org.apache.maven.plugins:maven-resources-plugin:2.6或其依赖项之一无法解析:无法读取org.apache.maven.plugins:maven-resources-plugin:jar:2.6的构件描述符

插件org.apache.maven.plugins:maven-resources-plugin:2.6或其依赖项之一无法解析:无法读取org.apache.maven.plugins:maven-resources-plugin:jar:2.6的构件描述符

无法计算构建计划:插件org.apache.maven.plugins:maven-resources-plugin:2.6或其依赖项之一无法解析:无法读取org.apache.maven.plugins:maven-resources-plugin:jar:2.6的构件描述符

插件org.apache.maven.plugins:maven-resources-plugin:2.6或其依赖项之一无法解析:无法读取org.apache.maven.plugins:maven-resources-plugin:jar:2.6的构件描述符

[图片](https://i.stack.imgur.com/RxtI5.png)

0
0 Comments

Maven依赖的JAR包没有更新或在Eclipse中出现错误的原因可能是由于以下情况之一:

1. 缺失的JAR包没有从库中移除。

2. 缺失的JAR包没有在pom.xml文件的dependencies标签中添加依赖。

解决方法:

1. 从库中移除所有缺失的JAR包。

2. 在pom.xml文件的dependencies标签中添加以下依赖:

<dependency>
     <groupId>org.springframework</groupId>
     <artifactId>spring-context</artifactId>
     <version>5.1.3.RELEASE</version>
</dependency>

3. 在项目上右键单击,点击"maven",然后点击"update project",或者按下(alt+F5)进行更新。

需要注意的是,升级Spring可能会导致应用程序出现问题,这个问题可能是由于下载Maven依赖而不是Spring本身引起的。如果没有看到Maven错误,无法确定问题所在。可以尝试在命令行/终端中构建项目并发布错误信息。

可能的错误信息如下:

coreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2: ArtifactResolutionException: Could not transfer artifact org.apache.maven.plugins:maven-compiler-plugin:pom:2.3.2 from/to central (repo.maven.apache.org/maven2): connect timed out

0
0 Comments

问题的出现原因:在Eclipse中,Maven依赖的jar包没有得到更新或出现错误。

解决方法:在项目的父模块中使用SpringBoot的起步依赖。

代码示例:


  org.springframework.boot
  spring-boot-starter-parent
  1.5.6.RELEASE

还有很多专门的起步依赖包,比如:


  org.springframework.boot
  spring-boot-starter

还有很多其他的起步依赖包,比如spring-boot-starter-web、spring-boot-starter-batch、spring-boot-starter-data-rest...

可以查看这篇博客文章了解更多信息。

这个解决方法很有帮助。

0
0 Comments

在POM.xml中添加springboot starters


    org.springframework.boot
    spring-boot-starter
    2.5.0

Update Maven project in Eclipse

1. Right-click on the project in Eclipse

2. Select "Maven" from the context menu

3. Click on "Update Project"

4. Check the "Force Update of Snapshots/Releases" box

5. Click on "OK"

Clean and rebuild the project

1. Right-click on the project in Eclipse

2. Select "Run As" from the context menu

3. Click on "Maven clean"

4. Once the clean process is finished, right-click on the project again

5. Select "Run As" from the context menu

6. Click on "Maven install"

Check for any errors in Eclipse

1. Open the "Problems" view in Eclipse

2. Look for any errors related to Maven dependencies

3. If there are errors, try resolving them by updating the POM.xml or fixing any other issues in the project

Make sure the correct Maven repository is configured

1. Open the "Preferences" in Eclipse

2. Go to "Maven" > "Repositories"

3. Make sure the correct Maven repository URL is added

4. If the URL is incorrect, add the correct URL and remove any incorrect or outdated repositories

Check for any conflicts or duplicates in Maven dependencies

1. Open the POM.xml file in Eclipse

2. Look for any duplicate dependencies or conflicts between different versions of the same dependency

3. Remove any duplicates or conflicts, and make sure only the required dependencies are included

Restart Eclipse

Sometimes, restarting Eclipse can resolve issues with Maven dependencies not getting updated or causing errors. Close Eclipse, wait a few seconds, and then reopen it. Try updating the Maven project and rebuilding it again.

By following these steps, you should be able to resolve the issue of Maven dependencies jars not getting updated or causing errors in Eclipse.

0