[TOC]
# 示例
> ## 基础 POM.xml
1. dependencies:依赖标签,用于声明项目的依赖jar包,这也是Maven的核心功能之一。
2. plugins:插件标签,用于配置各种构建插件,扩展Maven的功能。
3. build:构建标签,控制项目构建策略,比如编译版本、资源过滤、输出目录、插件执行顺序等。
4. profiles: profiles标签,定义不同环境(dev/test/prod)的构建profile,可以切换不同的依赖配置。
5. repositories:仓库标签,定义第三方jar包仓库,扩展 jar 包来源。
6. parent:继承父POM,实现项目重复配置的抽取与继承。
7. properties:属性标签,定义Maven常用变量,扩展POM的灵活性。
8. dependencyManagement:依赖管理标签,管理jar包版本,实现版本统一管理。
9. modules:模块标签,定义项目的子模块结构,实现模块依赖与继承。
10. scm:源码管理标签,定义项目的源码存放地址。方便开发人员获取最新源码。
```
<?xml version="1.0" encoding="UTF-8"?>
<!-- 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">
<!-- POM模型版本号 -->
<modelVersion>4.0.0</modelVersion>
<!-- 项目的组ID -->
<groupId>com.example</groupId>
<!-- 项目的唯一标识符 -->
<artifactId>example-project</artifactId>
<!-- 项目的版本号 -->
<version>1.0.0-SNAPSHOT</version>
<!-- 项目的打包方式,默认为jar -->
<packaging>jar</packaging>
<!-- 项目的名称 -->
<name>Example Project</name>
<!-- 项目的描述信息 -->
<description>This is an example project for demonstration purposes.</description>
<!-- 项目的主页地址 -->
<url>https://www.example.com</url>
<!-- 项目的许可证信息 -->
<licenses>
<license>
<name>Apache License 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<!-- 项目的开发者信息 -->
<developers>
<developer>
<id>johndoe</id>
<name>John Doe</name>
<email>johndoe@example.com</email>
<organization>Example Organization</organization>
<organizationUrl>https://www.example.com</organizationUrl>
<roles>
<role>developer</role>
</roles>
</developer>
</developers>
<!-- 项目的依赖关系 -->
<dependencies>
<!-- 项目的依赖项 -->
<dependency>
<!-- 依赖项的组ID -->
<groupId>com.example</groupId>
<!-- 依赖项的唯一标识符 -->
<artifactId>example-library</artifactId>
<!-- 依赖项的版本号 -->
<version>1.0.0</version>
<!-- 依赖项的作用范围 -->
<scope>compile</scope>
<!-- 是否为可选依赖 -->
<optional>false</optional>
<!-- 排除依赖项 -->
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<!-- 项目的仓库信息 -->
<repositories>
<!-- Maven仓库的地址和协议信息 -->
<repository>
<!-- 仓库的唯一标识符 -->
<id>central</id>
<!-- 仓库的URL地址 -->
<url>https://repo.maven.apache.org/maven2/</url>
</repository>
</repositories>
<!-- 项目的构建信息 -->
<build>
<!-- 源代码目录 -->
<sourceDirectory>src/main/java</sourceDirectory>
<!-- 最终构建产物的名称 -->
<finalName>example-project</finalName>
<!-- 项目的插件信息 -->
<plugins>
<!-- 项目的插件 -->
<plugin>
<!-- 插件的唯一标识符 -->
<groupId>org.apache.maven.plugins</groupId>
<!-- 插件的唯一标识符(续) -->
<artifactId>maven-compiler-plugin</artifactId>
<!-- 插件的版本号 -->
<version>3.8.1</version>
<!-- 插件的执行配置信息 -->
<executions>
<!-- 插件的执行配置 -->
<execution>
<!-- 配置项的激活条件 -->
<id>default-compile</id>
<!-- 插件的目标 -->
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<!-- 插件的配置信息 -->
<configuration>
<!-- 插件的配置项 -->
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
```
> ## 项目构建 build
```
<!-- 项目的构建信息 -->
<build>
<!-- 源代码目录 -->
<sourceDirectory>src/main/java</sourceDirectory>
<!-- 最终构建产物的名称 -->
<finalName>example-project</finalName>
<!-- 项目的插件信息 -->
<plugins>
<!-- 项目的插件 -->
<plugin>
<!-- 插件的唯一标识符 -->
<groupId>org.apache.maven.plugins</groupId>
<!-- 插件的唯一标识符(续) -->
<artifactId>maven-compiler-plugin</artifactId>
<!-- 插件的版本号 -->
<version>3.8.1</version>
<!-- 插件的执行配置信息 -->
<executions>
<!-- 插件的执行配置 -->
<execution>
<!-- 配置项的激活条件 -->
<id>default-compile</id>
<!-- 插件的目标 -->
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<!-- 插件的配置信息 -->
<configuration>
<!-- 插件的配置项 -->
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
```
> ## 项目仓库信息 repositories
```
<!-- 项目的仓库信息 -->
<repositories>
<!-- Maven仓库的地址和协议信息 -->
<repository>
<!-- 仓库的唯一标识符 -->
<id>central</id>
<!-- 仓库的URL地址 -->
<url>https://repo.maven.apache.org/maven2/</url>
</repository>
</repositories>
```
> ## 项目依赖信息
```
<!-- 项目的依赖关系 -->
<dependencies>
<!-- 项目的依赖项 -->
<dependency>
<!-- 依赖项的组ID -->
<groupId>com.example</groupId>
<!-- 依赖项的唯一标识符 -->
<artifactId>example-library</artifactId>
<!-- 依赖项的版本号 -->
<version>1.0.0</version>
<!-- 依赖项的作用范围 -->
<scope>compile</scope>
<!-- 是否为可选依赖 -->
<optional>false</optional>
<!-- 排除依赖项 -->
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
```
> ## 项目开发者信息
```
<!-- 项目的开发者信息 -->
<developers>
<developer>
<id>johndoe</id>
<name>John Doe</name>
<email>johndoe@example.com</email>
<organization>Example Organization</organization>
<organizationUrl>https://www.example.com</organizationUrl>
<roles>
<role>developer</role>
</roles>
</developer>
</developers>
```
>## PIG 项目 pom.xml 示例
```
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2020 pig4cloud Authors. All Rights Reserved.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
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.pig4cloud</groupId>
<artifactId>pig</artifactId>
<name>${project.artifactId}</name>
<!-- name标签定义项目显示名称,一般引用${project.artifactId}变量 -->
<version>3.6.5</version>
<packaging>pom</packaging>
<!-- packaging标签定义项目的打包方式,可选jar、war、pom等 -->
<url>https://www.pig4cloud.com</url>
<!-- properties标签定义项目属性,常用于定义版本号等 -->
<properties>
<spring-boot.version>2.7.7</spring-boot.version>
<spring-cloud.version>2021.0.5</spring-cloud.version>
<spring-cloud-alibaba.version>2021.0.4.0</spring-cloud-alibaba.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<spring-boot-admin.version>2.7.9</spring-boot-admin.version>
<spring.authorization.version>0.4.0</spring.authorization.version>
<dynamic-ds.version>3.6.0</dynamic-ds.version>
<captcha.version>2.2.2</captcha.version>
<velocity.version>2.3</velocity.version>
<velocity.tool.version>3.1</velocity.tool.version>
<configuration.version>1.10</configuration.version>
<jasypt.version>2.1.0</jasypt.version>
<swagger.fox.version>3.0.0</swagger.fox.version>
<knife4j.ui.version>3.0.3</knife4j.ui.version>
<xxl-job.version>2.3.1</xxl-job.version>
<docker.plugin.version>0.32.0</docker.plugin.version>
<docker.host>http://192.168.0.100:2375</docker.host>
<docker.registry>192.168.0.100</docker.registry>
<docker.namespace>pig4cloud</docker.namespace>
<docker.username>username</docker.username>
<docker.password>password</docker.password>
<git.commit.plugin>4.9.9</git.commit.plugin>
<spring.checkstyle.plugin>0.0.35</spring.checkstyle.plugin>
</properties>
<!-- dependencies标签定义项目的依赖 -->
<!-- 以下依赖 全局所有的模块都会引入 -->
<dependencies>
<!--配置文件处理器-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<!--配置文件加解密-->
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>${jasypt.version}</version>
</dependency>
<!--监控-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!--监控客户端-->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>${spring-boot-admin.version}</version>
</dependency>
<!--Lombok-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<!--测试依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<!-- modules标签定义项目的子模块 -->
<modules>
<module>pig-register</module>
<module>pig-gateway</module>
<module>pig-auth</module>
<module>pig-upms</module>
<module>pig-common</module>
<module>pig-visual</module>
<module>xudemo</module>
</modules>
<!-- dependencyManagement标签定义依赖管理,用于控制jar包的版本 -->
<dependencyManagement>
<dependencies>
<!--pig 公共版本定义-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common-bom</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- 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.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<!-- build标签定义项目的构建设置,比如编译版本、输出目录、插件配置等 -->
<build>
<finalName>${project.name}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<finalName>${project.build.finalName}</finalName>
<layers>
<enabled>true</enabled>
</layers>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker.plugin.version}</version>
<configuration>
<!-- Docker Remote Api-->
<dockerHost>${docker.host}</dockerHost>
<!-- Docker 镜像私服-->
<registry>${docker.registry}</registry>
<!-- 认证信息-->
<authConfig>
<push>
<username>${docker.username}</username>
<password>${docker.password}</password>
</push>
</authConfig>
<images>
<image>
<!-- 镜像名称: 172.17.0.111/library/pig-gateway:2.6.3-->
<name>${docker.registry}/${docker.namespace}/${project.name}:${project.version}</name>
<build>
<dockerFile>${project.basedir}/Dockerfile</dockerFile>
</build>
</image>
</images>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<!--打包jar 与git commit 关联插件-->
<plugin>
<groupId>io.github.git-commit-id</groupId>
<artifactId>git-commit-id-maven-plugin</artifactId>
<version>${git.commit.plugin}</version>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
<phase>initialize</phase>
</execution>
</executions>
<configuration>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<!--因为项目定制了jackson的日期时间序列化/反序列化格式,因此这里要进行配置,不然通过management.info.git.mode=full进行完整git信息监控时会存在问题-->
<dateFormat>yyyy-MM-dd HH:mm:ss</dateFormat>
<includeOnlyProperties>
<includeOnlyProperty>^git.build.(time|version)$</includeOnlyProperty>
<includeOnlyProperty>^git.commit.(id|message|time).*$</includeOnlyProperty>
</includeOnlyProperties>
</configuration>
</plugin>
<!--
代码格式插件,默认使用spring 规则,可运行命令进行项目格式化:./mvnw spring-javaformat:apply 或 mvn spring-javaformat:apply,可在IDEA中安装插件以下插件进行自动格式化:
https://repo1.maven.org/maven2/io/spring/javaformat/spring-javaformat-intellij-idea-plugin
-->
<plugin>
<groupId>io.spring.javaformat</groupId>
<artifactId>spring-javaformat-maven-plugin</artifactId>
<version>${spring.checkstyle.plugin}</version>
<executions>
<execution>
<phase>validate</phase>
<inherited>true</inherited>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!-- profiles标签定义环境切换profiles,可以根据不同环境进行依赖调整等设置 -->
<profiles>
<profile>
<id>dev</id>
<properties>
<!-- 环境标识,需要与配置文件的名称相对应 -->
<profiles.active>dev</profiles.active>
</properties>
<activation>
<!-- 默认环境 -->
<activeByDefault>true</activeByDefault>
</activation>
</profile>
</profiles>
</project>
```
- 系统设计
- 需求分析
- 概要设计
- 详细设计
- 逻辑模型设计
- 物理模型设计
- 产品设计
- 数据驱动产品设计
- 首页
- 逻辑理解
- 微服务架构的关系数据库优化
- Java基础架构
- 编程范式
- 面向对象编程【模拟现实】
- 泛型编程【参数化】
- 函数式编程
- 响应式编程【异步流】
- 并发编程【多线程】
- 面向切面编程【代码复用解耦】
- 声明式编程【注解和配置】
- 函数响应式编程
- 语法基础
- 包、接口、类、对象和切面案例代码
- Springboot按以下步骤面向切面设计程序
- 关键词
- 内部类、匿名类
- 数组、字符串、I/O
- 常用API
- 并发包
- XML
- Maven 包管理
- Pom.xml
- 技术框架
- SpringBoot
- 项目文件目录
- Vue
- Vue项目文件目录
- 远程组件
- 敏捷开发前端应用
- Pinia Store
- Vite
- Composition API
- uniapp
- 本地方法JNI
- 脚本机制
- 编译器API
- 注释
- 源码级注释
- Javadoc
- 安全
- Swing和图形化编程
- 国际化
- 精实或精益
- 精实软件数据库设计
- 精实的原理与方法
- 项目
- 零售软件
- 扩展
- 1001_docker 示例
- 1002_Docker 常用命令
- 1003_微服务
- 1004_微服务数据模型范式
- 1005_数据模型
- 1006_springCloud
- AI 流程图生成
- Wordpress_6
- Woocommerce_7
- WooCommerce常用的API和帮助函数
- WooCommerce的钩子和过滤器
- REST API
- 数据库API
- 模板系统
- 数据模型
- 1.Woo主题开发流程
- Filter
- Hook
- 可视编辑区域的函数工具
- 渲染字段函数
- 类库和框架
- TDD 通过测试来驱动开发
- 编程范式对WordPress开发
- WordPress和WooCommerce的核心代码类库组成
- 数据库修改
- 1.WP主题开发流程与时间规划
- moho
- Note 1
- 基础命令