天天看點

關于Springboot中maven說明1. SpringBoot加強

1. SpringBoot加強

1.1 關于maven說明

1.1.1 關于maven 動态依賴的說明

說明:圖中所示, 使用者直接導入junit-12版本,但是發現maven會自動的添加依賴項 探究如何實作的???

關于Springboot中maven說明1. SpringBoot加強

原理說明:

1. 當通過pom.xml檔案添加依賴項時,maven會工具坐标查找jar封包件.

2. 當加載jar包完成之後,會解析目前的POM.xml檔案,如果其中還有jar包的依賴項嗎,則再次解析加載jar包.

最終實作jar包傳遞性的實作.

1.1.2 jar封包件傳輸規則

SHA1介紹:

SHA-1(英語:Secure Hash Algorithm 1,中文名:安全雜湊演算法1)是一種密碼散列函數,美國國家安全局設計,并由美國國家标準技術研究所(NIST)釋出為聯邦資料處理标準(FIPS)。SHA-1可以生成一個被稱為消息摘要的160位(20位元組)散列值,散列值通常的呈現形式為40個十六進制數。

消息摘要資訊: 對原有的資料進行hash計算得到的結果稱之為摘要資訊.

關于Springboot中maven說明1. SpringBoot加強

通過摘要資訊對比是否一緻,可以判斷資料是否安全.

知識回顧:

1. 如果同一個資料進行hash計算 問:結果是相同的.

1.1 關于配置檔案說明

1.1.1 parent标簽作用

<!--
		作用1: parent标簽 集中定義了SpringBoot所有依賴jar包的版本資訊.
			   由官網解決了jar包沖突性問題.
		作用2: 本地倉庫中沒有該檔案的jar包 parent表示的是一個聚合工程(定義).
	-->
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.3.4.RELEASE</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
           

1.1.2 關于Maven指令執行

1.清空target檔案

2.編譯項目

3.項目打包操作

關于Springboot中maven說明1. SpringBoot加強

1.1.3 關于pro檔案說明

<!--maven項目配置資訊-->
	<properties>
		<!--指定了jdk版本資訊-->
		<java.version>1.8</java.version>
		<!--
			跳過測試類打包
			預設條件下程式打包會執行測試了類 如果測試類有問題,則程式打包失敗.
		-->
		<skipTests>true</skipTests>
	</properties>
           

1.1.4 關于依賴項的說明

開箱即用!!!

<dependencies>

		<!--
			手動依賴項 該依賴項被springBoot進行了高度的整合
			springBoot幫助大家動态的生成了配置項目,簡化了配置的步驟
			該配置稱之為自動化的配置資訊
			spring-boot-starter springBoot自動化的啟動項.
			開箱即用: 隻需要導入jar包簡單的配置即可實作對應的功能.
		-->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>

		<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>
	</dependencies>
           

3.1.5 關于build标簽作用

項目運作指令dos:

java  -jar  xxx.jar
           
<!--
		SpringBoot利用maven管理工具進行項目打包/釋出/等操作
		該标簽必須添加
	-->
	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>
           
關于Springboot中maven說明1. SpringBoot加強

繼續閱讀