【Maven打包报错误】找不到或无法加载主类以及Could not resolve dependencies,Failed to collect dependencies的解决办法

核心:file=>invalidate caches + 重新clean和install一下parent(maven父模块)模块

最开始碰到的问题是更新了代码但是Swagger中找不到Controller服务,http调用也not found。其实这时候运行的是缓存,然后clean了报找不到主类

正常来说是存在这个Application类的:

【Maven打包报错误】找不到或无法加载主类以及Could not resolve dependencies,Failed to collect dependencies的解决办法_第1张图片

1. 找不到主类先检查配置是否正确

【Maven打包报错误】找不到或无法加载主类以及Could not resolve dependencies,Failed to collect dependencies的解决办法_第2张图片

2. 重新Maven clean 和 install

进入相应模块目录下面执行:mvn clean install -e

提示信息如下:

[INFO] Error stacktraces are turned on.
[WARNING]
[WARNING] Some problems were encountered while building the effective settings
[WARNING] Unrecognised tag: 'mirror' (position: START_TAG seen ...\r\n    ... @138:13)  @ D:\ 应用\apache-maven-3.6.3-bin\apache-maven-3.6.3\bin\..\conf\settings.xml, line 138, column 13
[WARNING]
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< com.zeroone.star:crm-sample >---------------------
[INFO] Building crm-sample 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.817 s
[INFO] Finished at: 2023-10-21T21:57:49+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project crm-sample: Could not resolve dependencies for project com.zeroone.star:crm-sample:jar:1.0.0-SNAPSHOT: Failed to collect dependencies at com.zeroone.star:crm-common:jar:1.0.0-SNAPSHOT: Failed to read artifact descriptor for com.zeroone.star:crm-common:jar:1.0.0-SNAPSHOT: Failure to find com.zeroone.star:crm-parent:pom:${revision} in https://maven.aliyun.com/repository/public was cached in the local repository, resolution will not be reattempted until the update interval of aliyun has elapsed or updates are forced -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project crm-sample: Could not resolve dependencies for project com.zeroone.star:crm-sample:jar:1.0.0-SNAPSHOT: Failed to collect dependencies at com.zeroone.star:crm-common:jar:1.0.0-SNAPSHOT

3.观察报错信息可知Failed to collect dependencies at com.zeroone.star:crm-common:jar:1.0.0-SNAPSHOT:重新打包一下common

还是报错提示fastdfs-spring-boot-starter有问题

【Maven打包报错误】找不到或无法加载主类以及Could not resolve dependencies,Failed to collect dependencies的解决办法_第3张图片

4.重新clean和install一下parent

如果还是不行清掉IDEA缓存重新打开再进行以上步骤

PS:碰到Controller都删除了却还能运行服务的情况估计就是缓存作祟,以上办法已解决

你可能感兴趣的:(Java,maven,java)