# 简介 >[info] 简单说明如何使用maven构建单体仓库多模块工程 ## 什么是单体仓库 ![](https://img.kancloud.cn/cf/d9/cfd928927d9af5f457023b6ada69a994_1201x613.png) ## 如何搭建一个单体仓库多模块微服务工程 ### 1.sts :new --> othter ![](https://box.kancloud.cn/2e4f64275a41324e183cded31b8159be_1166x825.png) ### 2.选择maven项目 ![](https://box.kancloud.cn/5b1c34a75cfbbece0cabd5df20115557_1714x863.png) ### 3.create a simple project ![](https://box.kancloud.cn/54da843083d18d20fb43c3e7e2632aa0_1785x930.png) ### 4.input your group id artifact id  ,注意packageing选择pom方式 ![](https://box.kancloud.cn/10909384987a00174fddefee70e97268_1650x900.png) ### 5.上一步成功后,选择项目,new -->other ![](https://box.kancloud.cn/d6eef23b6b3cc262890b8f7e8e1b0551_1127x414.png) ### 6.选择新建子模块 ![](https://box.kancloud.cn/5b289d340fb69a774eb81c0ac819025c_1618x884.png) ### 7.新建注册中心 ![](https://box.kancloud.cn/9d32a80a170479a45e724638fd1452d8_1594x965.png) ![](https://box.kancloud.cn/d87bbd605ebe3b48bc3cb61f57634bb0_1824x911.png) 点击finish即可 ### 8.增加一下依赖 ![](https://box.kancloud.cn/3a1c14a781ad89fa68ca024a69eab1b5_1773x1018.png) ### pom.xml ```<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.capacity.platform</groupId> <artifactId>open-capacity-platform</artifactId> <version>1.0.1</version> <packaging>pom</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <core.version>1.0.1</core.version> <spring-platform.version>Cairo-SR3</spring-platform.version> <spring-boot.version>2.0.4.RELEASE</spring-boot.version> <spring-boot-dependencies.version>2.0.4.RELEASE</spring-boot-dependencies.version> <spring-cloud-dependencies.version>Finchley.SR2</spring-cloud-dependencies.version> </properties> <modules> <module>register-center</module> </modules> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>${spring-boot-dependencies.version}</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>io.spring.platform</groupId> <artifactId>platform-bom</artifactId> <version>${spring-platform.version}</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring-cloud-dependencies.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> </project> ``` ### 9.maven强制更新 ``` mvn clean install -e -U ``` ### 10.windows删除无用文件 ``` for /r %i in (\*.lastUpdated) do del %i ``` ## 单体仓库多模块的好处 * 统一的规范,语言,和IDE带来的是结构的完整稳定。 * 标准化的开发流程,规避很多不必要的冲突与错误。 ## 简单说明单体仓库多模块的持续集成 ``` node () { def workspace = pwd() stage 'Checkout' dir('open-capacity-platform'){ git branch: 'master', credentialsId: 'ocp', url:'https://gitee.com/owenwangwen/open-capacity-platform' } stage 'Build' sh""" cd $workspace/open-capacity-platform chmod 777 * /bin/apache-maven-3.3.9/bin/mvn clean install -DskipTests """ echo 'Build Success' stage 'build image' sh""" cp -R $workspace/open-capacity-platform/register-center/eureka-server/target/eureka-server.jar $workspace/open-capacity-platform/register-center/eureka-server/src/main/docker/eureka-server.jar cd $workspace/open-capacity-platform/register-center/eureka-server/src/main/docker/ docker build -t eureka-server:1.0.1 . """ stage 'push image' sh""" docker login -u owenwangwen -p 1q2w3e4r 130.75.3.171 docker tag eureka-server:1.0.1 130.75.3.171/ocp/eureka-server:1.0.1 docker push 130.75.3.171/ocp/eureka-server:1.0.1 """ } ```