5-Maven-setttings和pom.xml常用配置一览
setttings.xml配置
xml
复制代码
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>D:\MavenWarehouseBoCloud</localRepository>
<pluginGroups></pluginGroups>
<proxies></proxies>
<servers>
<server>
<id>bocloud</id>
<username>******</username>
<password>*******</password>
</server>
<server>
<id>bocloud-snapshot</id>
<username>******</username>
<password>*******</password>
</server>
</servers>
<mirrors>
<mirror>
<id>aliyun-central</id>
<mirrorOf>central</mirrorOf>
<name>aliyun-central</name>
<url>https://maven.aliyun.com/repository/central</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>bocloud</id>
<repositories>
<repository>
<id>bocloud</id>
<!-- 公司私服 -->
<url>http://****:**/##/maven-public/</url>
<releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>
<snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>bocloud</id>
<!-- 公司私服 -->
<url>http:/****:**/##/maven-public/</url>
<releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>
<snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>bocloud</activeProfile>
<!--bocloud.booter.tomcat 是对于我们公司来讲基本每个项目中pom.xml都会配置的profile所以直接在settings中设置启用了 -->
<activeProfile>bocloud.booter.tomcat</activeProfile>
</activeProfiles>
</settings>
pom.xml配置
父pom.xml
:
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>
<parent>
</parent>
<groupId>com.bocloud</groupId>
<artifactId>*.*</artifactId>
<version>XXX-LTS</version>
<packaging>pom</packaging>
<description>BoCloud Cloud Operation Platform</description>
<properties>
<bocloud.cop.version>XXX-LTS</bocloud.cop.version>
<bocloud.common.version>XXX-LTS</bocloud.common.version>
</properties>
<modules>
.......
<module>bocloud.cop.*</module>
</modules>
<dependencyManagement>
<dependencies>
...........
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.1.0</version>
</dependency>
</dependencies>
</dependencyManagement>
<distributionManagement>
<repository>
<id>bocloud</id>
<name>BoCloud Release</name>
<url>${release.server.url}</url>
</repository>
<snapshotRepository>
<id>bocloud-snapshot</id>
<name>BoCloud Snapshot</name>
<url>${snapshot.server.url}</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.4.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<updateReleaseInfo>true</updateReleaseInfo>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>21</source>
<target>21</target>
<encoding>${file_encoding}</encoding>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
<version>3.0.0-M3</version>
</plugin>
</plugins>
</build>
</project>
子pom.xml
: controller所在的module
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">
<parent>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>bocloud.cop.*</artifactId>
<version>${bocloud.booter.version}</version>
<dependencies>
........
<!--for spring boot 3-->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.7</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<parameters>true</parameters>
<source>21</source>
<target>21</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
<mainClass>com.bocloud.cop.***.Application</mainClass>
<addClasspath>true</addClasspath>
<useUniqueVersions>false</useUniqueVersions>
<classpathPrefix>libs/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.6.1</version>
<executions>
<execution>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<type>jar</type>
<includeTypes>jar</includeTypes>
<includeScope>runtime</includeScope>
<outputDirectory>${project.build.directory}/libs</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>bocloud.booter.tomcat</id>
<properties>
<bocloud.booter.version>****-LTS</bocloud.booter.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</profile>
</profiles>
</project>