maven打包失败与问题反思

背景

maven项目结构

ParentPom
 |--A
  |--C
  |--D
 |--B
  |--E
  |--F

A,B都是父模块,CDEF是子模块(springboot项目)

依赖关系是E-->C

问题

打包时,E编译失败,无法找到C下的包名

解决

参考:https://blog.csdn.net/g56467467464/article/details/102686608
核心原因是springboot默认打出的包无法被依赖
C模块原配置如下:

<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<executable>true</executable>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>repackage</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>

失败原因是C的问题
https://docs.spring.io/spring-boot/docs/1.5.6.RELEASE/reference/html/howto-build.html

最后:C的pom加一行

<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<classifier>exec</classifier>
					<executable>true</executable>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>repackage</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>

反思

  • 不知道自己在干啥
    首先必须得确定目前问题处在什么的环境,这个问题是没有意识到普通的maven打包插件与spring-boot的打包方式是有区别的
  • 错误思路
    以为是本地仓库中_remote.repositories,但是删除后仍然没用
    _remote.repositories只用于标明本资源来自哪里参考https://blog.csdn.net/lovepeacee/article/details/103094247
原文地址:https://www.cnblogs.com/gengqzh/p/14917697.html