SpringCloud多模块整理

1.项目架构

—— project        父项目

—— client        子项目(客户端)    对外暴露的接口

—————— pom.xml          子项目的pom文件

—— common    子项目(公共)    公用的对象

—————— pom.xml          子项目的pom文件

—— server    子项目(服务端)     所有业务逻辑

—————— pom.xml          子项目的pom文件

—— pom.xml    父项目的pom文件,主要配置子项目modules、版本信息或编码等properties、依赖管理dependencyManagement

 

2.父项目pom

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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0modelVersion>

 

<groupId>com.jzgroupId>
<artifactId>productartifactId>
<version>0.0.1-SNAPSHOTversion>
<modules>
<module>clientmodule>
<module>servermodule>
<module>commonmodule>
modules>
<packaging>pompackaging>


<name>productname>
<description>Demo project for Spring Bootdescription>


<parent>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-parentartifactId>
<version>2.0.1.RELEASEversion>
<relativePath/> 
parent>


<properties>
<project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8project.reporting.outputEncoding>
<java.version>1.8java.version>
<spring-cloud.version>Finchley.RC1spring-cloud.version>
<product-common.version>0.0.1-SNAPSHOTproduct-common.version>
properties>


<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloudgroupId>
<artifactId>spring-cloud-dependenciesartifactId>
<version>${spring-cloud.version}version>
<type>pomtype>
<scope>importscope>
dependency>
<dependency>
<groupId>com.jzgroupId>
<artifactId>product-commonartifactId>
<version>${product-common.version}version>
dependency>
dependencies>
dependencyManagement>


<repositories>
<repository>
<id>spring-milestonesid>
<name>Spring Milestonesname>
<url>https://repo.spring.io/milestoneurl>
<snapshots>
<enabled>falseenabled>
snapshots>
repository>
repositories>
project>

 

3.子项目pom文件

①    Client

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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0modelVersion>
<artifactId>product-clientartifactId>
<parent>
<groupId>com.jzgroupId>
<artifactId>productartifactId>
<version>0.0.1-SNAPSHOTversion>
parent>

<dependencies>
<dependency>
<groupId>org.springframework.cloudgroupId>
<artifactId>spring-cloud-starter-netflix-eureka-clientartifactId>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-webartifactId>
dependency>
<dependency>
<groupId>com.jzgroupId>
<artifactId>product-commonartifactId>
dependency>
<dependency>
<groupId>org.springframework.cloudgroupId>
<artifactId>spring-cloud-starter-openfeignartifactId>
dependency>
dependencies>
project>

 

 

②    Common

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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0modelVersion>
<artifactId>product-commonartifactId>

<parent>
<groupId>com.jzgroupId>
<artifactId>productartifactId>
<version>0.0.1-SNAPSHOTversion>
parent>

<dependencies>
<dependency>
<groupId>org.projectlombokgroupId>
<artifactId>lombokartifactId>
dependency>
dependencies>
project>

 

 

③    Server

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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0modelVersion>
<artifactId>product-serverartifactId>

 

<parent>
<groupId>com.jzgroupId>
<artifactId>productartifactId>
<version>0.0.1-SNAPSHOTversion>
parent>

<dependencies>
<dependency>
<groupId>org.springframework.cloudgroupId>
<artifactId>spring-cloud-starter-netflix-eureka-clientartifactId>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-testartifactId>
<scope>testscope>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-data-jpaartifactId>
dependency>
<dependency>
<groupId>mysqlgroupId>
<artifactId>mysql-connector-javaartifactId>
dependency>
<dependency>
<groupId>org.projectlombokgroupId>
<artifactId>lombokartifactId>
dependency>
<dependency>
<groupId>com.jzgroupId>
<artifactId>product-commonartifactId>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-webartifactId>
dependency>
dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-maven-pluginartifactId>
plugin>
plugins>
build>
project>

 

---------------------
作者:Imkarl
来源:CSDN
原文:https://blog.csdn.net/weixin_42123821/article/details/80241060
版权声明:本文为博主原创文章,转载请附上博文链接!

你可能感兴趣的:(SpringCloud多模块整理)