5-Maven-setttings和pom.xml常用配置一览

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>
相关推荐
WaaTong1 分钟前
《重学Java设计模式》之 原型模式
java·设计模式·原型模式
m0_743048441 分钟前
初识Java EE和Spring Boot
java·java-ee
AskHarries3 分钟前
Java字节码增强库ByteBuddy
java·后端
小灰灰__23 分钟前
IDEA加载通义灵码插件及使用指南
java·ide·intellij-idea
夜雨翦春韭27 分钟前
Java中的动态代理
java·开发语言·aop·动态代理
程序媛小果1 小时前
基于java+SpringBoot+Vue的宠物咖啡馆平台设计与实现
java·vue.js·spring boot
追风林1 小时前
mac m1 docker本地部署canal 监听mysql的binglog日志
java·docker·mac
芒果披萨1 小时前
El表达式和JSTL
java·el
duration~2 小时前
Maven随笔
java·maven
zmgst2 小时前
canal1.1.7使用canal-adapter进行mysql同步数据
java·数据库·mysql