由于maven在工作中经常使用,但是平时要记的知识点有点多,偶尔回头来看一些东西难免忘记,特此整理一篇笔记,方便大家搜索查询,也方便自己以后查询!
后续碰见其他的标签也会进行更新!
maven的pom文件中存在引入依赖、声明、继承;引入依赖的时候首先去本地仓库找,找不到再去配置的其他仓库找!
1.modelVersion
<modelVersion>4.0.0</modelVersion><!--描述这个POM文件是遵从哪个版本的项目描述符。-->
2.parent
<parent><!--父级依赖,继承--> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.2.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent>
3.dependencies
<dependencies><!--引入依赖--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> </dependency> </dependencies>
4.dependencyManagement
<!--声明依赖,如果dependencies中没有声明版本就会来这里面找-->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.BUILD-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
5.repositories
<!-- <!–相当于配置远程仓库–> <repositories> <repository> <id>spring-snapshots</id> <name>Spring Snapshots</name> <url>https://repo.spring.io/libs-snapshot</url> <!–是否自动更新–> <snapshots> <enabled>true</enabled> </snapshots> </repository> <repository> <id>spring-milestones</id> <name>Spring Milestones</name> <url>https://repo.spring.io/libs-milestone</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> <repository> <id>spring-releases</id> <name>Spring Releases</name> <url>https://repo.spring.io/libs-release</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories>
6.properties
<properties><!--定义的标签属性可以在其他地方读取--> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <start-class>eureka.EurekaApplication</start-class> <java.version>1.8</java.version> <docker.image.prefix2></docker.image.prefix2> </properties>
7.pluginRepositories
<!–插件仓库–>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/libs-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>-->
8.配置jdk版本
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build>