[ERROR] Failed to execute goal on project springcloud_emp: Could not resolve dependencies for project com.libin:springcloud_emp:jar:1.0.1-SNAPSHOT: Failed to collect dependencies at com.libin:springcloud_ems:pom:1.0.1-SNAPSHOT -> [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
问题描述:
D:\Java\jdk_8_windows_x64\bin\java.exe -Dmaven.multiModuleProjectDirectory=D:\JAVA_EE\Project\WorkSpace\MicroService\SpringCloudAlibaba\springcloud_ems -Xms256m -Xmx512m -Dfile.encoding=UTF-8 -Dmaven.home=D:\Java\apache_maven_3_6_1 -Dclassworlds.conf=D:\Java\apache_maven_3_6_1\bin\m2.conf -javaagent:D:\JAVA_EE\ideaIU_2018_3_6_win\lib\idea_rt.jar=9379:D:\JAVA_EE\ideaIU_2018_3_6_win\bin -classpath D:\Java\apache_maven_3_6_1\boot\plexus-classworlds-2.6.0.jar org.codehaus.classworlds.Launcher -Didea.version=2018.3.6 -s D:\Java\apache_maven_3_6_1\conf\settings.xml install [INFO] Scanning for projects... [INFO] [INFO] ---------------------< com.libin:springcloud_emp >---------------------- [INFO] Building springcloud_emp 1.0.1-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.156 s [INFO] Finished at: 2021-06-27T13:17:20+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal on project springcloud_emp: Could not resolve dependencies for project com.libin:springcloud_emp:jar:1.0.1-SNAPSHOT: Failed to collect dependencies at com.libin:springcloud_commons:jar:1.0.1-SNAPSHOT: Failed to read artifact descriptor for com.libin:springcloud_commons:jar:1.0.1-SNAPSHOT: Could not find artifact com.libin:springcloud_ems:pom:1.0.1-SNAPSHOT -> [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 Process finished with exit code 1
解决方案:
父项目的pom.xml如下:
<?xml version="1.0" encoding="UTF-8"?> <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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.5.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.libin</groupId> <artifactId>springcloud_ems</artifactId> <version>1.0.1-SNAPSHOT</version> <name>springcloud_ems</name> <description>父项目 project for Spring Boot</description> <packaging>pom</packaging> <modules> <module>springcloud_commons</module> <module>springcloud_emp</module> <module>springcloud_user</module> <module>springcloud_gateway</module> <module>springcloud_file</module> </modules> <properties> <java.version>1.8</java.version> <!--springcloud H版本目前最新版本 springcloud H版本之后可以与springcloud alibaba的2.x版本继承 --> <spring-cloud.version>Hoxton.SR6</spring-cloud.version> <!--引入springcloud alibaba--> <spring-cloud-alibaba.version>2.2.1.RELEASE</spring-cloud-alibaba.version> </properties> <!--全局引入springcloudalibaba下载依赖地址,并不会引入依赖--> <dependencyManagement> <dependencies> <!--springcloud下载依赖版本号 和具体位置--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring-cloud.version}</version> <type>pom</type> <scope>import</scope> </dependency> <!--使用springcloud alibaba组件依赖--> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-alibaba-dependencies</artifactId> <version>${spring-cloud-alibaba.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <!--打包插件 --> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <!--跳过springboot打包--> <skip> true </skip> </configuration> <executions> <execution> <goals> <!--可以把依赖的包都打包到生成的jar 包中 --> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>
注意:
根据这段配置全局控制需要打包的模块
<modules> <module>springcloud_commons</module> <module>springcloud_emp</module> <module>springcloud_user</module> <module>springcloud_gateway</module> <module>springcloud_file</module> </modules>
比如上图可以单独打包user模块
注:
父项目加入如下打包插件之后,其他模块就不要再加插件
<!--打包插件 --> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <!--跳过springboot打包--> <skip> true </skip> </configuration> <executions> <execution> <goals> <!--可以把依赖的包都打包到生成的jar 包中 --> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
如果大家觉得还不错,点赞,收藏,分享,一键三连支持我一下~