dependencies
通用依赖版本控制:依赖于一个二方库群时,必须定义一个统一的版本变量,避免版本号不一致。pom.xml
文件配置
<?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.0</modelVersion>
<groupId>com.qfdmy</groupId>
<artifactId>qfdmy-dependencies</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<url>http://www.qfdmy.com</url>
<inceptionYear>2020-Now</inceptionYear>
<description>通用依赖-Dependencies</description>
!-- 软件配置管理:配合 maven-release-plugin 插件使用 --
<scm>
<connection>scm:git:http://gitlab.funtl.com/qfdmy/qfdmy-dependencies.git</connection>
<developerConnection>scm:git:http://gitlab.funtl.com/qfdmy/qfdmy-dependencies.git</developerConnection>
<url>http://gitlab.funtl.com/qfdmy/qfdmy-dependencies</url>
</scm>
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
!-- Spring Projects --
<spring-boot.version>2.3.0.RELEASE</spring-boot.version>
<spring-cloud.version>Hoxton.SR4</spring-cloud.version>
<spring-cloud-alibaba.verion>2.2.1.RELEASE</spring-cloud-alibaba.verion>
!-- Cloud Service --
<qiniu.version>7.2.29</qiniu.version>
!-- Tools --
<mybatis-plus.version>3.3.1</mybatis-plus.version>
<hutool.version>5.3.5</hutool.version>
!-- Projects --
<qfdmy.version>1.0.0.RELEASE</qfdmy.version>
<qfdmy.development.version>1.0.1-SNAPSHOT</qfdmy.development.version>
</properties>
<developers>
<developer>
<id>liwemin</id>
<name>Lusifer Lee</name>
<email>lee.lusifer@gmail.com</email>
</developer>
</developers>
!-- 发布项目到 Nexus --
<distributionManagement>
<repository>
<id>nexus-releases</id>
<url>http://nexus.funtl.com/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<url>http://nexus.funtl.com/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<dependencyManagement>
<dependencies>
!-- Spring Boot --
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
!-- Spring Cloud --
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
!-- Spring Cloud Alibaba --
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>${spring-cloud-alibaba.verion}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
!-- MyBatisPlus --
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatis-plus.version}</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>${mybatis-plus.version}</version>
</dependency>
!-- HuTool --
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>${hutool.version}</version>
</dependency>
!-- 七牛云 --
<dependency>
<groupId>com.qiniu</groupId>
<artifactId>qiniu-java-sdk</artifactId>
<version>${qiniu.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
!-- Maven 多环境配置 --
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
!-- 用于自动发布 RELEASE TAG --
<maven-release-plugin.version>2.5.3</maven-release-plugin.version>
!-- 配合 maven-release-plugin 插件发布到 Git(GitLab,GitHub 等) --
<maven-scm-provider-jgit-plugin.version>1.9.5</maven-scm-provider-jgit-plugin.version>
!-- Spring 提供的代码美化插件 --
<spring-javaformat-maven-plugin.version>0.0.22</spring-javaformat-maven-plugin.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>io.spring.javaformat</groupId>
<artifactId>spring-javaformat-maven-plugin</artifactId>
<version>${spring-javaformat-maven-plugin.version}</version>
</plugin>
!-- mvn scm --
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>${maven-release-plugin.version}</version>
<configuration>
<providerImplementations>
<git>jgit</git>
</providerImplementations>
<username>root</username>
<password>12345678</password>
<tagBase>${project.artifactId}-${project.version}</tagBase>
<goals>-f pom.xml deploy</goals>
<releaseLabel>${qfdmy.version}</releaseLabel>
<releaseVersion>${qfdmy.version}</releaseVersion>
<developmentVersion>${qfdmy.development.version}</developmentVersion>
<preparationGoals>clean verify</preparationGoals>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-jgit</artifactId>
<version>${maven-scm-provider-jgit-plugin.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
下面的仓库地址已全部配置到 Nexus 中,此处仅当作记录
<repositories>
<repository>
<id>aliyun-nexus</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestone</id>
<name>Spring Milestone</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-snapshot</id>
<name>Spring Snapshot</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-milestone</id>
<name>Spring Milestone</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-snapshot</id>
<name>Spring Snapshot</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
parent工程
<?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.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.0.RELEASE</version>
</parent>
<groupId>com.qfdmy</groupId>
<artifactId>qfdmy-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<url>http://www.qfdmy.com</url>
<inceptionYear>2020-Now</inceptionYear>
<description>通用依赖-Parent</description>
<scm>
<connection>scm:git:http://gitlab.funtl.com/qfdmy/qfdmy-parent.git</connection>
<developerConnection>scm:git:http://gitlab.funtl.com/qfdmy/qfdmy-parent.git</developerConnection>
<url>http://gitlab.funtl.com/qfdmy/qfdmy-parent</url>
</scm>
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
!-- Projects --
<qfdmy.version>1.0.0.RELEASE</qfdmy.version>
<qfdmy.development.version>1.0.1-SNAPSHOT</qfdmy.development.version>
</properties>
<developers>
<developer>
<id>liwemin</id>
<name>Lusifer Lee</name>
<email>lee.lusifer@gmail.com</email>
</developer>
</developers>
<distributionManagement>
<repository>
<id>nexus-releases</id>
<url>http://nexus.funtl.com/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<url>http://nexus.funtl.com/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.qfdmy</groupId>
<artifactId>qfdmy-dependencies</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
!-- Maven 多环境配置 --
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<maven-clean-plugin.version>3.1.0</maven-clean-plugin.version>
<maven-install-plugin.version>3.0.0-M1</maven-install-plugin.version>
<maven-release-plugin.version>2.5.3</maven-release-plugin.version>
<maven-javadoc-plugin.version>3.1.1</maven-javadoc-plugin.version>
<maven-surefire-plugin.version>3.0.0-M4</maven-surefire-plugin.version>
<maven-enforcer-plugin.version>3.0.0-M3</maven-enforcer-plugin.version>
<maven-scm-provider-jgit-plugin.version>1.9.5</maven-scm-provider-jgit-plugin.version>
<spring-javaformat-maven-plugin.version>0.0.22</spring-javaformat-maven-plugin.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>io.spring.javaformat</groupId>
<artifactId>spring-javaformat-maven-plugin</artifactId>
<version>${spring-javaformat-maven-plugin.version}</version>
</plugin>
!-- mvn clean --
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>${maven-clean-plugin.version}</version>
<configuration>
<filesets>
!-- 清理 JRebel 产生的备份文件 --
<fileset>
<directory>${basedir}/**</directory>
<includes>
<include>.rebel.xml.bak</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
!-- mvn install --
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>${maven-install-plugin.version}</version>
</plugin>
!-- JavaDoc 生成插件 --
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven-javadoc-plugin.version}</version>
<configuration>
!-- 生成 HTML 后 title 的名字 --
<windowtitle>千锋达摩院 ${project.version} JavaDocs</windowtitle>
!--
解决控制台乱码问题
需要在【环境变量】中添加【系统变量】
- 变量名:JAVA_TOOL_OPTIONS
- 变量值:-Dfile.encoding=UTF-8
--
<charset>UTF8</charset>
<encoding>UTF8</encoding>
<docencoding>UTF8</docencoding>
!--
生成 JavaDoc 所在目录:reportOutputDirectory/destDir
- reportOutputDirectory:输出的目录位置
- destDir:文档生成的目录位置
--
<destDir>javadocs</destDir>
<reportOutputDirectory>${basedir}/docs</reportOutputDirectory>
</configuration>
</plugin>
!-- 测试用例插件 --
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
!-- 设置默认跳过测试 --
<skip>true</skip>
<includes>
<include>**/*Tests.java</include>
</includes>
<excludes>
<exclude>**/Abstract*.java</exclude>
</excludes>
<systemPropertyVariables>
<java.security.egd>file:/dev/./urandom</java.security.egd>
<java.awt.headless>true</java.awt.headless>
</systemPropertyVariables>
</configuration>
</plugin>
!--
依赖冲突检查
在进行 mvn clean package 的时候,会在 console 中打印出冲突的 jar 版本和其父 pom
--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>${maven-enforcer-plugin.version}</version>
<executions>
<execution>
<id>enforce-rules</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<bannedDependencies>
<excludes>
<exclude>commons-logging:*:*</exclude>
</excludes>
<searchTransitive>true</searchTransitive>
</bannedDependencies>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
!-- mvn scm --
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>${maven-release-plugin.version}</version>
<configuration>
<providerImplementations>
<git>jgit</git>
</providerImplementations>
<username>root</username>
<password>12345678</password>
<tagBase>${project.artifactId}-${project.version}</tagBase>
<goals>-f pom.xml deploy</goals>
<releaseLabel>${qfdmy.version}</releaseLabel>
<releaseVersion>${qfdmy.version}</releaseVersion>
<developmentVersion>${qfdmy.development.version}</developmentVersion>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-jgit</artifactId>
<version>${maven-scm-provider-jgit-plugin.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
commons工程
通用类库工具类:如 HuTool 等开源类库依赖
<?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.0</modelVersion>
<parent>
<groupId>com.qfdmy</groupId>
<artifactId>qfdmy-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>qfdmy-commons</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<url>http://www.qfdmy.com</url>
<inceptionYear>2020-Now</inceptionYear>
<description>通用依赖-Commons</description>
<scm>
<connection>scm:git:http://gitlab.funtl.com/qfdmy/qfdmy-commons.git</connection>
<developerConnection>scm:git:http://gitlab.funtl.com/qfdmy/qfdmy-commons.git</developerConnection>
<url>http://gitlab.funtl.com/qfdmy/qfdmy-commons</url>
</scm>
<developers>
<developer>
<id>liwemin</id>
<name>Lusifer Lee</name>
<email>lee.lusifer@gmail.com</email>
</developer>
</developers>
<dependencies>
!-- Jackson --
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
!-- Commons --
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
独立项目
generator
通用代码生成器:如 MyBatis Plus 等其它开源类库或自定义代码生成器
<?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.0</modelVersion>
<parent>
<groupId>com.qfdmy</groupId>
<artifactId>qfdmy-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>qfdmy-generator</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<url>http://www.qfdmy.com</url>
<inceptionYear>2020-Now</inceptionYear>
<description>代码生成器</description>
<scm>
<connection>scm:git:http://gitlab.funtl.com/qfdmy/qfdmy-generator.git</connection>
<developerConnection>scm:git:http://gitlab.funtl.com/qfdmy/qfdmy-generator.git</developerConnection>
<url>http://gitlab.funtl.com/qfdmy/qfdmy-generator</url>
</scm>
<developers>
<developer>
<id>liwemin</id>
<name>Lusifer Lee</name>
<email>lee.lusifer@gmail.com</email>
</developer>
</developers>
<dependencies>
!-- Datasource --
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
!-- MyBatisPlus --
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
</dependency>
!-- Commons --
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
</project>
数据持久层
repository
数据持久层:与底层 MySQL、 Oracle、 Hbase 等进行数据交互。
<?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.0</modelVersion>
<parent>
<groupId>com.qfdmy</groupId>
<artifactId>qfdmy-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>qfdmy-repository</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<url>http://www.qfdmy.com</url>
<inceptionYear>2020-Now</inceptionYear>
<description>持久层</description>
<scm>
<connection>scm:git:http://gitlab.funtl.com/qfdmy/qfdmy-repository.git</connection>
<developerConnection>scm:git:http://gitlab.funtl.com/qfdmy/qfdmy-repository.git</developerConnection>
<url>http://gitlab.funtl.com/qfdmy/qfdmy-repository</url>
</scm>
<developers>
<developer>
<id>liwemin</id>
<name>Lusifer Lee</name>
<email>lee.lusifer@gmail.com</email>
</developer>
</developers>
<modules>
!-- 服务模块 --
</modules>
<dependencies>
!-- Spring Boot --
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
!-- DataSource --
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
!-- MyBatis Plus --
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
!-- Validator --
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
!-- Commons --
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
第三方平台
cloud
外部接口或第三方平台:包括其它部门 RPC 开放接口,基础平台,其它公司的 HTTP 接口。
<?xml version="1.0" encoding="UTF-8"?>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.qfdmy</groupId>
<artifactId>qfdmy-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>qfdmy-cloud</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<url>http://www.qfdmy.com</url>
<inceptionYear>2020-Now</inceptionYear>
<description>第三方平台服务或其他部门开放接口</description>
<scm>
<connection>scm:git:http://gitlab.funtl.com/qfdmy/qfdmy-cloud.git</connection>
<developerConnection>scm:git:http://gitlab.funtl.com/qfdmy/qfdmy-cloud.git</developerConnection>
<url>http://gitlab.funtl.com/qfdmy/qfdmy-cloud</url>
</scm>
<developers>
<developer>
<id>liwemin</id>
<name>Lusifer Lee</name>
<email>lee.lusifer@gmail.com</email>
</developer>
</developers>
<modules>
!-- 服务模块 --
</modules>
<dependencies>
!-- Spring Boot --
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
!-- Spring Security --
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</dependency>
!-- Tools --
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
</dependency>
!-- Commons --
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
!-- Projects --
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>qfdmy-commons</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>