由於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>