springboot的pop.xml配置文件三大組成部分

pop.xml文件的配置可以分爲三大組成部分。

一、繼承:一個maven項目是不是Spring Boot項目,就看它的pop.xml文件是否繼承了spring-boot-starter-parent啓動器。

         <parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.3.0.RELEASE</version>
		<relativePath/> <!-- lookup parent from repository -->
	 </parent>

二、依賴:根據不同應用場景導入不同場景的所依賴的啓動器(jar包座標)。

  Spring Boot項目所需的44個啓動器總結在:https://blog.csdn.net/luqingshuai_eloong/article/details/106202718

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

三、插件:

① spring-boot-maven-plugin這個插件是Spring Boot項目必須的一個插件,在項目打包發佈時能將項目依賴的所有jar包都打包到項目中,否則項目會缺少jar包。

       <build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章