Maven pom.xml文件基础配置

引子

以下是我感觉对自己有帮助的一些maven pom文件初始配置,主要用于以后自己配置(怕忘了)

Pom.xml文件关于依赖的标签

Dependencies:是可选依赖(Optional Dependencies)
Exclusions:是依赖排除(Dependency Exclusions)

<!-- 可选依赖 -->
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-test</artifactId>
	<scope>test</scope>
	<!-- 依赖排除 -->
	<exclusions>
		<exclusion>
			<groupId>org.junit.vintage</groupId>
			<artifactId>junit-vintage-engine</artifactId>
		</exclusion>
	</exclusions>
</dependency>

归类依赖: maven会将pom中的所有的${es.version}替换成实际值7.2.0

<properties>
    <es.version>7.2.0<es.version>
</properties>

<!--引用时案例-->
<dependency>
	<groupId>org.elasticsearch.client</groupId>
	<artifactId>elasticsearch-rest-high-level-client</artifactId>
	<version>${es.version}</version><!--$NO-MVN-MAN-VER$ -->
</dependency>

Pom.xml文件中 repositories 和 pluginRepositories标签含义

可以不用配置直接在maven的setting.xml文件中配置

<!-- 用来配置maven项目的远程仓库 -->
	<repositories>
		<repository>
			<id>spring-milestones</id>
			<name>Spring Milestones</name>
			<url>https://repo.spring.io/milestone</url>
		</repository>
		<repository>
			<id>spring-snapshots</id>
			<name>Spring Snapshots</name>
			<url>https://repo.spring.io/snapshot</url>
			<snapshots>
				<enabled>true</enabled> <!--snapshots默认是关闭的,需要开启  -->
			</snapshots>
		</repository>
	</repositories>
	
	<!-- 用来配置maven插件的远程仓库 -->
	<pluginRepositories>
		<pluginRepository>
			<id>spring-milestones</id>
			<name>Spring Milestones</name>
			<url>https://repo.spring.io/milestone</url>
		</pluginRepository>
		<pluginRepository>
			<id>spring-snapshots</id>
			<name>Spring Snapshots</name>
			<url>https://repo.spring.io/snapshot</url>
			<snapshots>
				<enabled>true</enabled> <!--snapshots默认是关闭的,需要开启  -->
			</snapshots>
		</pluginRepository>
	</pluginRepositories>

Maven pom.xml文件抑制警告 <!--$NO-MVN-MAN-VER$-->

<!--$NO-MVN-MAN-VER$-->  

案例:

<dependency>  
    <groupId>junit</groupId>  
    <artifactId>junit</artifactId>  
    <version>3.8.1</version><!--$NO-MVN-MAN-VER$-->  
    <scope>test</scope>  
</dependency>  

编写时所引用和借鉴的url

 

猜你喜欢

转载自blog.csdn.net/huqiwuhuiju/article/details/107769087