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.其他问题?
请在评论区说明
至此表示多模块项目基本搭建成功,文章若有不足之处,欢迎指正。