--- title: 'Spring Boot Error解決方法' disqus: hackmd --- ###### tags: `SpringBoot` Spring Boot Error解決方法 === [TOC] ## 帳戶管理系統的bug Could not resolve dependencies问题的解决 ### error message ```java [INFO] Scanning for projects... [INFO] [INFO] --------< com.AccountManagementSystem:AccountManagementSystem >--------- [INFO] Building AccountManagementSystem 0.0.1 [INFO] --------------------------------[ war ]--------------------------------- [WARNING] The POM for com.EncapsulationSystem:EncapsulationSystem:jar:1.0 is missing, no dependency information available [WARNING] The POM for jc:adwords-encapsulation:jar:1.0 is missing, no dependency information available [WARNING] The POM for com.PermissionSystemApiTool:PermissionSystemApiTool:jar:0.0.1 is missing, no dependency information available [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.674 s [INFO] Finished at: 2021-11-15T11:48:15+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal on project AccountManagementSystem: Could not resolve dependencies for project com.AccountManagementSystem:AccountManagementSystem:war:0.0.1: The following artifacts could not be resolved: com.EncapsulationSystem:EncapsulationSystem:jar:1.0, jc:adwords-encapsulation:jar:1.0, com.PermissionSystemApiTool:PermissionSystemApiTool:jar:0.0.1: com.EncapsulationSystem:EncapsulationSystem:jar:1.0 was not found in https://repo.maven.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central 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: ``` ```java= [INFO] Scanning for projects... [INFO] [INFO] --------< com.AccountManagementSystem:AccountManagementSystem >--------- [INFO] Building AccountManagementSystem 0.0.1 [INFO] --------------------------------[ war ]--------------------------------- [INFO] Downloading from : https://repo.maven.apache.org/maven2/com/EncapsulationSystem/EncapsulationSystem/1.0/EncapsulationSystem-1.0.pom [WARNING] The POM for com.EncapsulationSystem:EncapsulationSystem:jar:1.0 is missing, no dependency information available [INFO] Downloading from : https://repo.maven.apache.org/maven2/jc/adwords-encapsulation/1.0/adwords-encapsulation-1.0.pom [WARNING] The POM for jc:adwords-encapsulation:jar:1.0 is missing, no dependency information available [INFO] Downloading from : https://repo.maven.apache.org/maven2/com/PermissionSystemApiTool/PermissionSystemApiTool/0.0.1/PermissionSystemApiTool-0.0.1.pom [WARNING] The POM for com.PermissionSystemApiTool:PermissionSystemApiTool:jar:0.0.1 is missing, no dependency information available [INFO] Downloading from : https://repo.maven.apache.org/maven2/com/EncapsulationSystem/EncapsulationSystem/1.0/EncapsulationSystem-1.0.jar [INFO] Downloading from : https://repo.maven.apache.org/maven2/com/PermissionSystemApiTool/PermissionSystemApiTool/0.0.1/PermissionSystemApiTool-0.0.1.jar [INFO] Downloading from : https://repo.maven.apache.org/maven2/jc/adwords-encapsulation/1.0/adwords-encapsulation-1.0.jar [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.800 s [INFO] Finished at: 2021-11-15T16:47:06+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal on project AccountManagementSystem: Could not resolve dependencies for project com.AccountManagementSystem:AccountManagementSystem:war:0.0.1: The following artifacts could not be resolved: com.EncapsulationSystem:EncapsulationSystem:jar:1.0, jc:adwords-encapsulation:jar:1.0, com.PermissionSystemApiTool:PermissionSystemApiTool:jar:0.0.1: Could not find artifact com.EncapsulationSystem:EncapsulationSystem:jar:1.0 in central (https://repo.maven.apache.org/maven2) -> [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 ``` ### 嘗試過的方法 1. 砍掉maven m2 file folder 沒用 2. deleting .remote.repositories 似乎沒用 ### 可能的方法 1.[Maven打包时报错Could not resolve dependencies for project](https://www.cnblogs.com/ycyzharry/p/9641120.html) 沒用 2.[Maven Could not resolve dependencies, artifacts could not be resolved](https://stackoverflow.com/questions/4650460/maven-could-not-resolve-dependencies-artifacts-could-not-be-resolved) https://stackoverflow.com/questions/45730541/the-pom-for-is-missing-no-dependency-information-available-even-though-it When you are building a multi-module Maven project, you need to run Maven commands from the root POM. This means you need to run mvn clean install on Product's pom.xml. The error you are getting is expected: you are only building Model. In Model's POM, Maven sees that there is a dependency on MagniCompCommon so it tries to look for that dependency. First, it searches in your local repo: it fails to find it there since you did not install MagniCompCommon before. As a result, it looks for it in the predefined remote repositories (and also fails to find it). You would be able to circumvent this by first running mvn clean install on MagniCompCommon's POM, then on Model POM but this is much easier done by invoking Maven directly on the root POM. It will correctly build every modules in the right order (since Model depends on MagniCompCommon, it will build MagniCompCommon first, then Model). As a side note, you can remove the line <packaging>jar</packaging> because this is the default. [Maven doesn't recognize sibling modules when running mvn dependency:tree](https://stackoverflow.com/questions/24673671/mavenerror-failed-to-execute-goal-on-project-could-not-resolve-dependencies-in) ### 解決方法可行的 1. 先清空所有對應的repository ![](https://i.imgur.com/TuEYo9t.png) 2. 依序install專案 3. 檢查war檔裡面是不是空包彈 ![](https://i.imgur.com/mlXMwJe.png) ### Eclipse 不用看 Run a custom maven command in Eclipse as follows: Right-click the maven project or pom.xml Expand Run As Select Maven Build... > Set Goals to the command, such as: clean install -X > Note: Eclipse prefixes the command with mvn automatically. ##