依赖已导入,已下载,无法使用问题
明明已经导入依赖,却无法使用相关注解
于是,我使用
mvn dependency:tree -Dverbose
来查看是否有依赖冲突
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project agileboot-infrastructure: Could not resolve dependencies for project com.agileboot:agileb
oot-infrastructure:jar:1.0.0: com.agileboot:agileboot-common:jar:1.0.0 was not found in http://maven.aliyun.com/nexus/content/repos
itories/central/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted untilthe update interval of alimaven has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <args> -rf :agileboot-infrastructure
发现agileboot-common
是当前项目的子模块(而不是外部依赖),那么这个错误通常是因为 Maven 没有先构建并安装该子模块到本地仓库,导致 agileboot-infrastructure
模块在解析依赖时找不到它。
mvn clean install
于是我尝试对整个项目进行构建
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project agileboot-co
mmon: Compilation failure: Compilation failure:
[ERROR] 读取D:\maven\apache-maven-3.8.7\repository\org\springframework\spring-expression\5.3.26\spring-expression-5.3.26.jar时出错;error in opening zip file
[ERROR] 读取D:\maven\apache-maven-3.8.7\repository\org\springframework\spring-web\5.3.26\spring-web-5.3.26.jar时出错; error in open
ing zip file
[ERROR] 读取D:\maven\apache-maven-3.8.7\repository\com\alibaba\fastjson2\fastjson2\2.0.49\fastjson2-2.0.49.jar时出错; error in open
ing zip file
[ERROR] 读取D:\maven\apache-maven-3.8.7\repository\org\springframework\spring-expression\5.3.26\spring-expression-5.3.26.jar时出错;error in opening zip file
[ERROR] 读取D:\maven\apache-maven-3.8.7\repository\org\springframework\spring-web\5.3.26\spring-web-5.3.26.jar时出错; error in open
ing zip file
[ERROR] 读取D:\maven\apache-maven-3.8.7\repository\com\alibaba\fastjson2\fastjson2\2.0.49\fastjson2-2.0.49.jar时出错; error in open
ing zip file
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/http/Ht
tpClientUtil.java:[32,32] 程序包org.springframework.http不存在
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/http/Ht
tpClientUtil.java:[33,32] 程序包org.springframework.http不存在
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/http/Ht
tpClientUtil.java:[34,32] 程序包org.springframework.http不存在
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/http/Ht
tpClientUtil.java:[35,32] 程序包org.springframework.http不存在
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/http/Ht
tpClientUtil.java:[36,32] 程序包org.springframework.http不存在
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/http/Ht
tpClientUtil.java:[37,42] 程序包org.springframework.http.converter不存在
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/http/Ht
tpClientUtil.java:[39,38] 程序包org.springframework.web.client不存在
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/http/Ht
tpClientUtil.java:[57,19] 找不到符号
[ERROR] 符号: 类 RestTemplate
[ERROR] 位置: 类 com.agileboot.common.utils.http.HttpClientUtil
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/http/Ht
tpClientUtil.java:[366,67] 找不到符号
[ERROR] 符号: 类 MediaType
[ERROR] 位置: 类 com.agileboot.common.utils.http.HttpClientUtil
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/http/Ht
tpClientUtil.java:[366,88] 找不到符号
[ERROR] 符号: 类 HttpMethod
[ERROR] 位置: 类 com.agileboot.common.utils.http.HttpClientUtil
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/config/RestTe
mplateConfig.java:[4,39] 程序包org.springframework.http.client不存在
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/config/RestTe
mplateConfig.java:[5,38] 程序包org.springframework.web.client不存在
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/config/RestTe
mplateConfig.java:[25,63] 找不到符号
[ERROR] 符号: 类 ResponseErrorHandler
[ERROR] 位置: 类 com.agileboot.common.config.RestTemplateConfig
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/config/RestTe
mplateConfig.java:[28,33] 找不到符号
[ERROR] 符号: 类 ClientHttpResponse
[ERROR] 位置: 类 com.agileboot.common.config.RestTemplateConfig.AcceptResponseErrorHandler
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/config/RestTe
mplateConfig.java:[33,33] 找不到符号
[ERROR] 符号: 类 ClientHttpResponse
[ERROR] 位置: 类 com.agileboot.common.config.RestTemplateConfig.AcceptResponseErrorHandler
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/core/base/Bas
eController.java:[8,36] 程序包org.springframework.web.bind不存在
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/core/base/Bas
eController.java:[9,47] 程序包org.springframework.web.bind.annotation不存在
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/core/base/Bas
eController.java:[22,28] 找不到符号
[ERROR] 符号: 类 WebDataBinder
[ERROR] 位置: 类 com.agileboot.common.core.base.BaseController
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/Servlet
HolderUtil.java:[5,47] 程序包org.springframework.web.context.request不存在
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/Servlet
HolderUtil.java:[6,47] 程序包org.springframework.web.context.request不存在
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/Servlet
HolderUtil.java:[7,47] 程序包org.springframework.web.context.request不存在
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/Servlet
HolderUtil.java:[49,19] 找不到符号
[ERROR] 符号: 类 ServletRequestAttributes
[ERROR] 位置: 类 com.agileboot.common.utils.ServletHolderUtil
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/Servlet
HolderUtil.java:[79,45] 找不到符号
[ERROR] 符号: 类 ServletRequestAttributes
[ERROR] 位置: 类 com.agileboot.common.utils.ServletHolderUtil
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/Servlet
HolderUtil.java:[138,19] 找不到符号
[ERROR] 符号: 类 ServletRequestAttributes
[ERROR] 位置: 类 com.agileboot.common.utils.ServletHolderUtil
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/SpringC
ontextUtils.java:[8,47] 程序包org.springframework.web.context.request不存在
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/SpringC
ontextUtils.java:[9,47] 程序包org.springframework.web.context.request不存在
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/poi/Cus
tomExcelUtil.java:[11,41] 程序包org.springframework.web.multipart不存在
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/poi/Cus
tomExcelUtil.java:[39,63] 找不到符号
[ERROR] 符号: 类 MultipartFile
[ERROR] 位置: 类 com.agileboot.common.utils.poi.CustomExcelUtil
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/file/Fi
leUploadUtils.java:[17,32] 程序包org.springframework.http不存在
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/file/Fi
leUploadUtils.java:[20,41] 程序包org.springframework.web.multipart不存在
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/file/Fi
leUploadUtils.java:[69,48] 找不到符号
[ERROR] 符号: 类 MultipartFile
[ERROR] 位置: 类 com.agileboot.common.utils.file.FileUploadUtils
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/file/Fi
leUploadUtils.java:[86,48] 找不到符号
[ERROR] 符号: 类 MultipartFile
[ERROR] 位置: 类 com.agileboot.common.utils.file.FileUploadUtils
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/file/Fi
leUploadUtils.java:[102,33] 找不到符号
[ERROR] 符号: 类 MultipartFile
[ERROR] 位置: 类 com.agileboot.common.utils.file.FileUploadUtils
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/file/Fi
leUploadUtils.java:[135,33] 找不到符号
[ERROR] 符号: 类 MultipartFile
[ERROR] 位置: 类 com.agileboot.common.utils.file.FileUploadUtils
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/file/Fi
leUploadUtils.java:[184,36] 找不到符号
[ERROR] 符号: 类 MultipartFile
[ERROR] 位置: 类 com.agileboot.common.utils.file.FileUploadUtils
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/file/Fi
leUploadUtils.java:[196,36] 找不到符号
[ERROR] 符号: 类 MultipartFile
[ERROR] 位置: 类 com.agileboot.common.utils.file.FileUploadUtils
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/utils/file/Fi
leUploadUtils.java:[210,19] 找不到符号
[ERROR] 符号: 类 HttpHeaders
[ERROR] 位置: 类 com.agileboot.common.utils.file.FileUploadUtils
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/app/WebContex
tFilter.java:[6,38] 程序包org.springframework.web.filter不存在
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/app/WebContex
tFilter.java:[16,39] 找不到符号
[ERROR] 符号: 类 OncePerRequestFilter
[ERROR] /C:/Users/one/IdeaProjects/personnel-matching-backend-bak/agileboot-common/src/main/java/com/agileboot/common/core/base/Bas
eController.java:[21,6] 找不到符号
[ERROR] 符号: 类 InitBinder
[ERROR] 位置: 类 com.agileboot.common.core.base.BaseController
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <args> -rf :agileboot-common
发现有一大堆依赖文件损坏,解决方法就是删除所有报错的依赖
# 进入 Maven 本地仓库目录(根据日志路径调整)
cd D:\maven\apache-maven-3.8.7\repository
# 删除损坏的依赖
rm -rf org/springframework/spring-expression/5.3.26/
rm -rf org/springframework/spring-web/5.3.26/
rm -rf com/alibaba/fastjson2/2.0.49/
删除后重新构建
mvn clean install -U
构建成功
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:10 min
[INFO] Finished at: 2025-06-17T22:08:11+08:00
[INFO] ------------------------------------------------------------------------
PS C:\Users\one\IdeaProjects\personnel-matching-backend-bak>
问题解决