【框架】eclipse中使用Maven创建多模块项目

eclipse使用Maven创建多模块项目

模块说明

父模块 :test-parent
…公共模块:test-common
…后台模块:test-admin
…app模块:test-app

创建步骤

1.创建父模块项目: test-parent
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述在这里插入图片描述
父模块项目创建成功,我们可以删除里面没用的目录(src等等),留下pom.xml文件

2.创建公共模块:test-common,步骤如下在这里插入图片描述
在这里插入图片描述在这里插入图片描述
在这里插入图片描述
公共模块项目创建成功

3.创建后台模块:test-admin及app模块:test-app,步骤同上,创建结构如下
在这里插入图片描述

常见问题解决

1.发现创建的test-app和test-admin项目下都是空的,如何启动?

可以参考上一篇博客 使用Maven创建Spring Boot项目

2.test-app和test-admin模块如何依赖test-common模块?

在test-app和test-admin模块中添加test-common模块的依赖
在这里插入图片描述
3.父模块打包maven install报错(Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.4.RELEASE:repackage (default) on project test-common: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:2.0.4.RELEASE:repackage failed: Unable to find main class -> [Help 1])?

报错项目中pom.xml添加

<build>
<finalName>${project.artifactId}</finalName>
<plugins>
	<plugin>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-maven-plugin</artifactId>
		<configuration>
			<mainClass>com.test.AdminApplication</mainClass>
		</configuration>
		<executions> 
			<execution> 
				<goals> 
					<goal>repackage</goal> 
				</goals> 
			</execution> 
		</executions>
	</plugin>
	<plugin>
		<groupId>org.apache.maven.plugins</groupId>
		<artifactId>maven-surefire-plugin</artifactId>
		<configuration>
			<skipTests>true</skipTests>
		</configuration>
	</plugin>
</plugins>
</build>

其中mainClass中的值为报错项目的启动类位置

4.其他问题?

请在评论区说明

至此表示多模块项目基本搭建成功,文章若有不足之处,欢迎指正。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值