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>
相关推荐
尘浮生2 分钟前
Java项目实战II基于微信小程序的校运会管理系统(开发文档+数据库+源码)
java·开发语言·数据库·微信小程序·小程序·maven·intellij-idea
小白不太白9506 分钟前
设计模式之 模板方法模式
java·设计模式·模板方法模式
Tech Synapse8 分钟前
Java根据前端返回的字段名进行查询数据的方法
java·开发语言·后端
xoxo-Rachel15 分钟前
(超级详细!!!)解决“com.mysql.jdbc.Driver is deprecated”警告:详解与优化
java·数据库·mysql
乌啼霜满天24917 分钟前
JDBC编程---Java
java·开发语言·sql
色空大师29 分钟前
23种设计模式
java·开发语言·设计模式
闲人一枚(学习中)30 分钟前
设计模式-创建型-建造者模式
java·设计模式·建造者模式
2202_754421541 小时前
生成MPSOC以及ZYNQ的启动文件BOOT.BIN的小软件
java·linux·开发语言
蓝染-惣右介1 小时前
【MyBatisPlus·最新教程】包含多个改造案例,常用注解、条件构造器、代码生成、静态工具、类型处理器、分页插件、自动填充字段
java·数据库·tomcat·mybatis