参考:https://blog.csdn.net/Sunshineoe/article/details/121083505
<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>io.qargroupId>
<artifactId>qar-commons-dependenciesartifactId>
<packaging>pompackaging>
<version>${revision}version>
<properties>
<revision>3.10.0revision>
<project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8project.reporting.outputEncoding>
<java.version>1.8java.version>
<knife4j.version>2.0.9knife4j.version>
<spring.boot.admin.version>2.7.5spring.boot.admin.version>
<captcha.version>1.6.2captcha.version>
<druid.version>1.2.12druid.version>
<mybatisplus.version>3.5.2mybatisplus.version>
<sqlserver.version>4.0sqlserver.version>
<oracle.version>11.2.0.3oracle.version>
<dameng.version>8.1.2.141dameng.version>
<commons.lang.version>3.7commons.lang.version>
<commons.fileupload.version>1.3.3commons.fileupload.version>
<commons.io.version>2.6commons.io.version>
<hutool.version>5.7.22hutool.version>
<easyexcel.version>3.0.5easyexcel.version>
<joda.time.version>2.9.9joda.time.version>
<gson.version>2.8.6gson.version>
<jsoup.version>1.11.3jsoup.version>
<lombok.version>1.18.22lombok.version>
<xxl-job.version>2.3.1xxl-job.version>
<quartz.version>2.3.2quartz.version>
<aliyun.core.version>3.2.2aliyun.core.version>
<aliyun.dysmsapi.version>1.1.0aliyun.dysmsapi.version>
<qcloud.qcloudsms.version>1.0.5qcloud.qcloudsms.version>
<qiniu.version>7.10.4qiniu.version>
<aliyun.oss.version>2.8.3aliyun.oss.version>
<qcloud.cos.version>5.4.4qcloud.cos.version>
<fastdfs.version>1.27.2fastdfs.version>
<minio.version>8.4.1minio.version>
<freemarker.version>2.3.31freemarker.version>
<mail.version>1.6.2mail.version>
<ureport2.version>2.2.9ureport2.version>
<IJPay.version>2.8.2IJPay.version>
<weixin-java-mp.version>4.2.0weixin-java-mp.version>
<xstream.version>1.4.20xstream.version>
<spring-security-oauth2.version>2.3.8.RELEASEspring-security-oauth2.version>
properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.qargroupId>
<artifactId>qar-commons-dynamic-datasourceartifactId>
<version>${revision}version>
dependency>
<dependency>
<groupId>io.qargroupId>
<artifactId>qar-commons-lockartifactId>
<version>${revision}version>
dependency>
<dependency>
<groupId>io.qargroupId>
<artifactId>qar-commons-logartifactId>
<version>${revision}version>
dependency>
<dependency>
<groupId>io.qargroupId>
<artifactId>qar-commons-mybatisartifactId>
<version>${revision}version>
dependency>
<dependency>
<groupId>io.qargroupId>
<artifactId>qar-commons-securityartifactId>
<version>${revision}version>
dependency>
<dependency>
<groupId>io.qargroupId>
<artifactId>qar-commons-swaggerartifactId>
<version>${revision}version>
dependency>
<dependency>
<groupId>io.qargroupId>
<artifactId>qar-commons-toolsartifactId>
<version>${revision}version>
dependency>
<dependency>
<groupId>io.qargroupId>
<artifactId>qar-commons-xxl-jobartifactId>
<version>${revision}version>
dependency>
<dependency>
<groupId>com.github.whvcsegroupId>
<artifactId>easy-captchaartifactId>
<version>${captcha.version}version>
dependency>
<dependency>
<groupId>org.projectlombokgroupId>
<artifactId>lombokartifactId>
<version>${lombok.version}version>
dependency>
<dependency>
<groupId>com.oraclegroupId>
<artifactId>ojdbc6artifactId>
<version>${oracle.version}version>
dependency>
<dependency>
<groupId>com.microsoft.sqlservergroupId>
<artifactId>sqljdbc4artifactId>
<version>${sqlserver.version}version>
dependency>
<dependency>
<groupId>com.damenggroupId>
<artifactId>DmJdbcDriver18artifactId>
<version>${dameng.version}version>
dependency>
<dependency>
<groupId>com.baomidougroupId>
<artifactId>mybatis-plus-boot-starterartifactId>
<version>${mybatisplus.version}version>
dependency>
<dependency>
<groupId>com.alibabagroupId>
<artifactId>druid-spring-boot-starterartifactId>
<version>${druid.version}version>
dependency>
<dependency>
<groupId>com.github.xiaoymingroupId>
<artifactId>knife4j-spring-boot-starterartifactId>
<version>${knife4j.version}version>
dependency>
<dependency>
<groupId>org.apache.commonsgroupId>
<artifactId>commons-lang3artifactId>
<version>${commons.lang.version}version>
dependency>
<dependency>
<groupId>commons-fileuploadgroupId>
<artifactId>commons-fileuploadartifactId>
<version>${commons.fileupload.version}version>
dependency>
<dependency>
<groupId>commons-iogroupId>
<artifactId>commons-ioartifactId>
<version>${commons.io.version}version>
dependency>
<dependency>
<groupId>cn.hutoolgroupId>
<artifactId>hutool-allartifactId>
<version>${hutool.version}version>
dependency>
<dependency>
<groupId>com.alibabagroupId>
<artifactId>easyexcelartifactId>
<version>${easyexcel.version}version>
dependency>
<dependency>
<groupId>joda-timegroupId>
<artifactId>joda-timeartifactId>
<version>${joda.time.version}version>
dependency>
<dependency>
<groupId>com.google.code.gsongroupId>
<artifactId>gsonartifactId>
<version>${gson.version}version>
dependency>
<dependency>
<groupId>org.jsoupgroupId>
<artifactId>jsoupartifactId>
<version>${jsoup.version}version>
dependency>
<dependency>
<groupId>com.xuxueligroupId>
<artifactId>xxl-job-coreartifactId>
<version>${xxl-job.version}version>
dependency>
<dependency>
<groupId>de.codecentricgroupId>
<artifactId>spring-boot-admin-starter-serverartifactId>
<version>${spring.boot.admin.version}version>
dependency>
<dependency>
<groupId>org.quartz-schedulergroupId>
<artifactId>quartzartifactId>
<version>${quartz.version}version>
dependency>
<dependency>
<groupId>com.aliyungroupId>
<artifactId>aliyun-java-sdk-coreartifactId>
<version>${aliyun.core.version}version>
dependency>
<dependency>
<groupId>com.aliyungroupId>
<artifactId>aliyun-java-sdk-dysmsapiartifactId>
<version>${aliyun.dysmsapi.version}version>
dependency>
<dependency>
<groupId>com.github.qcloudsmsgroupId>
<artifactId>qcloudsmsartifactId>
<version>${qcloud.qcloudsms.version}version>
dependency>
<dependency>
<groupId>com.qiniugroupId>
<artifactId>qiniu-java-sdkartifactId>
<version>${qiniu.version}version>
dependency>
<dependency>
<groupId>com.aliyun.ossgroupId>
<artifactId>aliyun-sdk-ossartifactId>
<version>${aliyun.oss.version}version>
dependency>
<dependency>
<groupId>com.qcloudgroupId>
<artifactId>cos_apiartifactId>
<version>${qcloud.cos.version}version>
dependency>
<dependency>
<groupId>com.github.tobatogroupId>
<artifactId>fastdfs-clientartifactId>
<version>${fastdfs.version}version>
dependency>
<dependency>
<groupId>io.miniogroupId>
<artifactId>minioartifactId>
<version>${minio.version}version>
dependency>
<dependency>
<groupId>com.sun.mailgroupId>
<artifactId>javax.mailartifactId>
<version>${mail.version}version>
dependency>
<dependency>
<groupId>org.freemarkergroupId>
<artifactId>freemarkerartifactId>
<version>${freemarker.version}version>
dependency>
<dependency>
<groupId>com.bstek.ureportgroupId>
<artifactId>ureport2-consoleartifactId>
<version>${ureport2.version}version>
dependency>
<dependency>
<groupId>com.github.javen205groupId>
<artifactId>IJPay-AliPayartifactId>
<version>${IJPay.version}version>
dependency>
<dependency>
<groupId>com.github.binarywanggroupId>
<artifactId>weixin-java-mpartifactId>
<version>${weixin-java-mp.version}version>
dependency>
<dependency>
<groupId>com.thoughtworks.xstreamgroupId>
<artifactId>xstreamartifactId>
<version>${xstream.version}version>
dependency>
<dependency>
<groupId>org.springframework.security.oauthgroupId>
<artifactId>spring-security-oauth2artifactId>
<version>${spring-security-oauth2.version}version>
dependency>
dependencies>
dependencyManagement>
project>
project-root的pom
<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>
<parent>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-parentartifactId>
<version>2.7.7version>
parent>
<groupId>io.qargroupId>
<artifactId>qar-cloudartifactId>
<version>${revision}version>
<packaging>pompackaging>
<description>qar微服务平台,是基于Spring Cloud打造的微服务平台,为企业提供一站式微服务解决方案!description>
<organization>
<name>qarname>
<url>https://www.qar.io/communityurl>
organization>
<modules>
<module>qar-commonsmodule>
<module>qar-gatewaymodule>
<module>qar-monitormodule>
<module>qar-authmodule>
<module>qar-adminmodule>
<module>qar-modulemodule>
<module>qar-newmodule>
modules>
<properties>
<revision>3.10.0revision>
<project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8project.reporting.outputEncoding>
<java.version>1.8java.version>
<spring.cloud.version>2021.0.5spring.cloud.version>
<spring.cloud.alibaba.version>2021.0.4.0spring.cloud.alibaba.version>
properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloudgroupId>
<artifactId>spring-cloud-starter-bootstrapartifactId>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-configuration-processorartifactId>
<optional>trueoptional>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-testartifactId>
<scope>testscope>
dependency>
<dependency>
<groupId>com.alibaba.nacosgroupId>
<artifactId>nacos-clientartifactId>
<version>2.1.1version>
dependency>
<dependency>
<groupId>org.springframework.cloudgroupId>
<artifactId>spring-cloud-starter-openfeignartifactId>
dependency>
<dependency>
<groupId>org.springframework.cloudgroupId>
<artifactId>spring-cloud-starter-loadbalancerartifactId>
dependency>
<dependency>
<groupId>com.github.ben-manes.caffeinegroupId>
<artifactId>caffeineartifactId>
dependency>
dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloudgroupId>
<artifactId>spring-cloud-dependenciesartifactId>
<version>${spring.cloud.version}version>
<type>pomtype>
<scope>importscope>
dependency>
<dependency>
<groupId>com.alibaba.cloudgroupId>
<artifactId>spring-cloud-alibaba-dependenciesartifactId>
<version>${spring.cloud.alibaba.version}version>
<type>pomtype>
<scope>importscope>
dependency>
<dependency>
<groupId>io.qargroupId>
<artifactId>qar-commons-dependenciesartifactId>
<version>${revision}version>
<type>pomtype>
<scope>importscope>
dependency>
dependencies>
dependencyManagement>
<repositories>
<repository>
<id>publicid>
<name>aliyun nexusname>
<url>https://maven.aliyun.com/repository/public/url>
<releases>
<enabled>trueenabled>
releases>
repository>
repositories>
<pluginRepositories>
<pluginRepository>
<id>publicid>
<name>aliyun nexusname>
<url>https://maven.aliyun.com/repository/public/url>
<releases>
<enabled>trueenabled>
releases>
<snapshots>
<enabled>falseenabled>
snapshots>
pluginRepository>
pluginRepositories>
project>
<modules>
<module>qar-commonsmodule>
<module>qar-gatewaymodule>
<module>qar-monitormodule>
<module>qar-authmodule>
<module>qar-adminmodule>
<module>qar-modulemodule>
<module>qar-newmodule>
modules>
<parent>
<groupId>io.qargroupId>
<artifactId>qar-cloudartifactId>
<version>${revision}version>
parent>
<groupId>io.qargroupId>
<artifactId>qar-commonsartifactId>
<packaging>pompackaging>
每个模块的变量先在当前配置中查找,如果没有就去父模块查找:
<version>${revision}version>
<properties>
<revision>3.10.0revision>
<project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8project.reporting.outputEncoding>
<java.version>1.8java.version>
<spring.cloud.version>2021.0.5spring.cloud.version>
<spring.cloud.alibaba.version>2021.0.4.0spring.cloud.alibaba.version>
properties>
唯一的ID,一个描述性的name,远程仓库的url, true告诉Maven可以从这个仓库下载releases版本的构件
<repositories>
<repository>
<id>publicid>
<name>aliyun nexusname>
<url>https://maven.aliyun.com/repository/public/url>
<releases>
<enabled>trueenabled>
releases>
repository>
repositories>
<pluginRepositories>
<pluginRepository>
<id>publicid>
<name>aliyun nexusname>
<url>https://maven.aliyun.com/repository/public/url>
<releases>
<enabled>trueenabled>
releases>
<snapshots>
<enabled>falseenabled>
snapshots>
pluginRepository>
pluginRepositories>
运行Maven的时候,Maven所需要的任何构件都是直接从本地仓库获取的。如果本地仓库没有,它会首先尝试从远程仓库下载构件至本地仓库,然后再使用本地仓库的构件
当我们运行install的时候,Maven实际上是将项目生成的构件安装到了本地仓库,即只有install了之后,其它项目才能使用此项目生成的构件
pom:父类型都为pom类型, 在maven install时不会生成jar/war压缩包
<packaging>pompackaging>
jar:内部调用或者是作服务使用,是默认的打包方式,
这种打包方式意味着在maven build时会将这个项目中的所有java文件都进行编译形成.class文件,且按照原来的java文件层级结构放置,最终压缩为一个jar文件
<packaging>jarpackaging>
war:打包项目,用于在容器(Tomcat、Jetty等)上部署
war包与jar包非常相似,同样是编译后的.class文件按层级结构形成文件树后打包形成的压缩包。不同的是,它会将项目中依赖的所有jar包都放在WEB-INF/lib这个文件夹下
war包非常适合部署时使用,不再需要下载其他的依赖包,能够使用户拿到war包直接使用,因此它经常使用于微服务项目群中的入口项目的pom配置中
<packaging>warpackaging>
指定install打包的包名
<build>
<finalName>${project.artifactId}finalName>
build>
#默认的build
<build>
<defaultGoal>installdefaultGoal>
<directory>${basedir}/targetdirectory>
<finalName>${artifactId}-${version}finalName>
<filters>
<filter>filters/filter1.propertiesfilter>
filters>
...
build>
全局配置(project build)
针对整个项目的所有情况都有效
配置(profile build)
针对不同的profile配置
参考: https://blog.csdn.net/zmemorys/article/details/105406053
在A微服务中采用feign调用,一个服务提供当前服务使用的接口和提供给外部使用的接口,此时, 创建两个模块,一个模块给自身提供服务接口,一个模块提供外部使用的接口(这个模块有DTO的定义,有DTO的定义就需要swagger的配置)所以该模块中依赖swagger构件,为了减少重复代码自身服务的模块需要依赖外部模块的构件,使用它的DTO和swagger依赖构件。
当外部B服务调用前者A服务的openfeign时,为了不需要重复写feign调用,需要依赖前者的A服务构件,这样的结构设计可以最大程度的简化代码避免冗余代码出现,也可以很好的管理服务间的调用,服务的提供方和服务的调用方,内部服务和外部服务很好的隔离组织在一起啦!
qar-flow-server内部服务的pom配置:
依赖提供外部服务的qar-flow-client构件和调用三方服务的qar-admin-client构件,client构件中依赖swagger和tools工具构件;
<dependency>
<groupId>io.qargroupId>
<artifactId>qar-flow-clientartifactId>
<version>${revision}version>
dependency>
<dependency>
<groupId>io.qargroupId>
<artifactId>qar-admin-clientartifactId>
<version>${revision}version>
dependency>
<dependency>
<groupId>io.qargroupId>
<artifactId>qar-commons-logartifactId>
dependency>
<dependency>
<groupId>io.qargroupId>
<artifactId>qar-commons-mybatisartifactId>
dependency>
<scope>providedscope>
使用provided标签的好处是可以减小最终打包的项目的大小,避免将不必要的库打包进去。同时,也方便服务器在运行时提供具体的库。
在install打包的qar-commons-dynamic-datasource
的jar中,没有qar-commons-mybatis,但编译运行不受影响,如果有外部项目使用qar-commons-dynamic-datasource构件,就需要单独引入qar-commons-mybatis依赖构件;
好处: 既方便依赖包的使用,也防止重复打包,减少代码冗余,减轻服务器的磁盘占用
<artifactId>qar-commons-dynamic-datasourceartifactId>
<packaging>jarpackaging>
<dependencies>
<dependency>
<groupId>io.qargroupId>
<artifactId>qar-commons-mybatisartifactId>
<scope>providedscope>
dependency>
dependencies>
<build>
<finalName>${project.artifactId}finalName>
build>
qar-admin-server服务的pom配置依赖,qar-commons-mybatis和qar-commons-dynamic-datasource构件
<dependency>
<groupId>io.qargroupId>
<artifactId>qar-commons-mybatisartifactId>
dependency>
<dependency>
<groupId>io.qargroupId>
<artifactId>qar-commons-dynamic-datasourceartifactId>
dependency>