SpringBoot 的Pom 文件解读

参考下面文章的学习笔记:

spring boot中pom文件解读
搭建SpringBoot项目阶段groupId和artifactId怎么写呢?
springboot中pom文件详解
POM标签大全详解
springboot入门–pom文件解读
SpringBoot 常用依赖
spring-boot-starter家族成员简介
Spring Boot Starter 简介
在这里插入图片描述
SpringBoot 的Pom 文件解读_第1张图片

Pom文件的基本构成

几乎最简单的一个SpringBoot 项目的 Pom文件,通过她来了解一下Pom文件的基本构成;


<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	
	
	<modelVersion>4.0.0modelVersion> 	

	
	
	
	<parent>
		<groupId>org.springframework.bootgroupId>
		<artifactId>spring-boot-starter-parentartifactId>
		<version>2.5.5version>
		<relativePath/> 
	parent>

	
	<groupId>com.examplegroupId>
	<artifactId>nodepartifactId>
	<version>0.0.1-SNAPSHOTversion>
	

	<packaging>jarpackaging>

	<name>nodepname> 
	<url>http://www.qwqwq.com/banseonurl>
	<description>nodepdescription>

	<properties>
		<java.version>1.8java.version>
		<project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8project.reporting.outputEncoding>
	properties>


	
	<dependencies>
		
		<dependency>
			<groupId>org.springframework.bootgroupId>
			<artifactId>spring-boot-starter-testartifactId>
			<scope>testscope>
		dependency>
	dependencies>

	
	<build>
		
		<plugins>
			
			<plugin>
				<groupId>org.springframework.bootgroupId>
				<artifactId>spring-boot-maven-pluginartifactId>
			plugin>
		plugins>
	build>
project>

在这里插入图片描述

artifactId 和 name 区别?

groupId + artifactId 唯一确定当前项目;
name 是项目的名称、只是一般 artifactId 和 name 设置成一样的了;
SpringBoot 的Pom 文件解读_第2张图片SpringBoot 的Pom 文件解读_第3张图片

在这里插入图片描述

SpringBoot常用依赖

springboot 在配置上相比spring要简单许多, 其核心在于各种springboot starter; 由于springboot 的自动装配,在使用springboot搭建一个项目时, 只需要引入官方提供的starter, 就可以直接使用里面的功能, 免去了各种配置。

有关 Spring Boot Starter 命名规范:

  1. 所有官方发布的 Starter 都遵循以下命名模式:
    spring-boot-starter-* :其中 * 指特定的应用程序代号或名称,譬如 spring-boot-starter-jdbc
  2. 任何第三方提供的 Starter Starter 都遵循以下命名模式:
    *-spring-boot-starter :譬如 mybatis-spring-boot-starter
    应该将应用程序代号或名称作为前缀、 不能以 spring-boot 作为前缀,

spring-boot-starter

Spring Boot 核心 starter,包括自动配置支持,日志和YAML

<dependency>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starterartifactId>
dependency>

spring-boot-starter-web

​ 对全栈web开发的支持,包括Tomcat和spring-webmvc

<dependency>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starter-webartifactId>
dependency>

数据访问层

Mybatis+Mapper

<mybatis-spring-boot-starter.version>1.3.2mybatis-spring-boot-starter.version>

<dependency>
    <groupId>org.mybatis.spring.bootgroupId>
    <artifactId>mybatis-spring-boot-starterartifactId>
    <version>${mybatis-spring-boot-starter.version}version>
dependency>
<mapper-spring-boot-starter.version>1.1.7mapper-spring-boot-starter.version>

<dependency>
    <groupId>tk.mybatisgroupId>
    <artifactId>mapper-spring-boot-starterartifactId>
    <version>${mapper-spring-boot-starter.version}version>
dependency>

关系型数据库

spring-boot-starter-jdbc

对JDBC数据库的支持

<dependency>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starter-jdbcartifactId>
dependency>

mysql

MySQL驱动

<mysql-connector-java.version>8.0.15mysql-connector-java.version>


<dependency>
    <groupId>mysqlgroupId>
    <artifactId>mysql-connector-javaartifactId>
    <scope>runtimescope>
dependency>

oracle

Oracle驱动

<oracle.version>11.2oracler.version>

<dependency>
   <groupId>org.oraclegroupId>
   <artifactId>oracleartifactId>
   <version>${oracle.version}version>
dependency>

非关系型数据库

spring-boot-starter-data-mongodb

对MongoDB 数据库的支持,包括spring-data-mongodb

<dependency>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starter-data-mongodbartifactId>
dependency>

spring-boot-starter-redis

对REDIS数据库的支持,包括Spring-redis

<dependency>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starter-redisartifactId>
dependency>

连接池

druid

<druid.version>1.1.5druid.version>

<dependency>  
    <groupId>com.alibabagroupId>  
    <artifactId>druidartifactId>  
    <version>${druid.version}version>  
dependency>

HikariCP

<dependency>
   <groupId>com.zaxxergroupId>
   <artifactId>HikariCPartifactId>
dependency>

测试

spring-boot-starter-test

对常用测试依赖的支持,包括JUnit, Hamcrest和Mockito,还有spring-test模块

<dependency>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starter-testartifactId>
    <scope>testscope>
dependency>

权限控制

spring-boot-starter-security

对spring -security模板引擎的支持

<dependency>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starter-securityartifactId>
dependency>

shiro-spring

​ 备注:(权限控制

<shrio-spring.version>1.4.0shrio-spring.version>

<dependency>
    <groupId>org.apache.shirogroupId>
    <artifactId>shiro-springartifactId>
    <version>${shrio-spring.version}version>
dependency>

监控中心及注册中心

Dubbo+Zookeeper

<dubbo-spring-boot-starter.version>0.2.1.RELEASEdubbo-spring-boot.version>

<dependency>
    <groupId>com.alibaba.bootgroupId>
    <artifactId>dubbo-spring-boot-starterartifactId>
    <version>${dubbo-spring-boot-starter.version}version>
dependency>

springCloud

​ (父工程)

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloudgroupId>
            <artifactId>spring-cloud-dependenciesartifactId>
            <version>Finchley.M9version>
            <type>pomtype>
            <scope>importscope>
        dependency>
    dependencies>
dependencyManagement>

​ springCloud+eureka 模块(注册)

<dependency>
	<groupId>org.springframework.cloudgroupId>
	<artifactId>spring-cloud-starter-netflix-eureka-serverartifactId>
dependency>

​ springCloud+客户端(调用)

<dependency>
	<groupId>org.springframework.cloudgroupId>
	<artifactId>spring-cloud-starter-netflix-eureka-clientartifactId>
dependency>
<dependency>
	<groupId>org.springframework.cloudgroupId>
	<artifactId>spring-cloud-starter-openfeignartifactId>
dependency>

JSON格式转换

fastjson

<fastjson.version>1.2.16fastjson.version>

<dependency>
   <groupId>com.alibabagroupId>
   <artifactId>fastjsonartifactId>
   <version>${fastjson.version}version>
dependency>

jackson-databind


<jackson-databind.version>2.9.8jackson-databindversion>


<dependency>
    <groupId>com.fasterxml.jackson.coregroupId>
    <artifactId>jackson-databindartifactId>
    <version>${jackson-databind.version}version>
dependency>

gson

<gson.version>2.8.5gson.version>

<dependency>
    <groupId>com.google.code.gsongroupId>
    <artifactId>gsonartifactId>
    <version>${gson.version}version>
dependency>

commons组件

commons-lang3

用于java.lang层次结构中的类,或被认为是标准的,以证明java.lang中的存在

<commons.lang3.version>3.7commons.lang3.version>

<dependency>
    <groupId>org.apache.commonsgroupId>
    <artifactId>commons-lang3artifactId>
    <version>${commons.lang3.version}version>
dependency>

commons-io

包含实用程序类,流实现,文件过滤器,文件比较器,endian转换类等等

<commons.io.version>2.6commons.io.version>

<dependency>
    <groupId>commons-iogroupId>
    <artifactId>commons-ioartifactId>
    <version>${commons.io.version}version>
dependency>

commons-collections4

扩展和扩充Java Collections Framework的类型


<commons-collections4.version>4.3<commons-collections4.version>

<dependency>
    <groupId>org.apache.commonsgroupId>
    <artifactId>commons-collections4artifactId>
    <version>${commons-collections4.version}version>
dependency>

commons-logging

允许与其他众所周知的日志记录系统进行可配置的桥接


<commons-logging.version>1.2commons-logging.version>
<dependency>
    <groupId>commons-logginggroupId>
    <artifactId>commons-loggingartifactId>
    <version>${commons-logging.version}version>
dependency>

常用工具

监控 spring-boot-starter-actuator

<dependency>
   <groupId>org.springframework.bootgroupId>
   <artifactId>spring-boot-starter-actuatorartifactId>
dependency>

日志 spring-boot-starter-log4j2

org.springframework.boot spring-boot-starter-log4j2

日志 slf4j-api


<slf4j-api.version>1.8.0-beta4slf4j-api.version>
<dependency>
    <groupId>org.slf4jgroupId>
    <artifactId>slf4j-apiartifactId>
    <version>${slf4j-api.version}version>
dependency>

lombok 简化JavaBean开发

简化JavaBean开发

<lombok.version>1.8.16lombok.version>
<dependency>
    <groupId>org.projectlombokgroupId>
    <artifactId>lombokartifactId>
    <version>${lombok.version}version>
dependency>

分页插件 pagehelper-spring-boot-start

分页插件

<pagehelper-spring-boot-starter.version>1.25pagehelper-spring-boot-starter>

<dependency>
    <groupId>com.github.pagehelpergroupId>
    <artifactId>pagehelper-spring-boot-starterartifactId>
    <version>${pagehelper-spring-boot-starter.version}version>
dependency>

spring-boot-starter-freemaker

对FreeMarker模板引擎的支持

<dependency>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starter-freemarkerartifactId>
dependency>

spring-boot-starter-mail

对javax.mail的支持

<dependency>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starter-mailartifactId>
dependency>

文件上传

<commons-fileupload.version>1.3.1commons-fileupload.version>

<fastdfs-client.version>1.25-RELEASEfastdfs-client.version>

<dependency>
    <groupId>commons-fileuploadgroupId>
    <artifactId>commons-fileuploadartifactId>
    <version>${commons-fileupload.version}version>
dependency>
<dependency>
    <groupId>org.csourcegroupId>
    <artifactId>fastdfs-clientartifactId>
    <version>${fastdfs-client.version}version>
dependency>

POI导入/导出

<poi.version>3.16poi.version>
<poi-ooxml.version>3.14poi-ooxml.version>

<dependency>
    <groupId>org.apache.poigroupId>
    <artifactId>poiartifactId>
    <version>${poi.version}version>
dependency>
<dependency>
    <groupId>org.apache.poigroupId>
    <artifactId>poi-ooxmlartifactId>
    <version>${poi-ooxml.version}version>
dependency>

activiti 工作流

<activiti-engine.version>7-201802-EAactiviti-engine.version>
<dependency>
    <groupId>org.activitigroupId>
    <artifactId>activiti-engineartifactId>
    <version>${activiti-engine.version}version>
dependency>

验证码

<kaptcha.version>2.3.2kaptcha.version>
<dependency>
    <groupId>com.github.pengglegroupId>
    <artifactId>kaptchaartifactId>
    <version>${kaptcha.version}version>
dependency>

阿里云发送短信

<aliyun-java-sdk-core.version>3.3.1aliyun-java-sdk-core.version>

<aliyun-java-sdk-dysmsapi.version>1.0.0aliyun-java-sdk-dysmsapi.version>

<dependency>
    <groupId>com.aliyungroupId>
    <artifactId>aliyun-java-sdk-coreartifactId>
    <version>${aliyun-java-sdk-core.version}version>
dependency>
<dependency>
    <groupId>com.aliyungroupId>
    <artifactId>aliyun-java-sdk-dysmsapiartifactId>
    <version>${aliyun-java-sdk-dysmsapi.version}version>
dependency>

微信支付

<wxpay-sdk.version>0.0.3wxpay-sdk.version>
<dependency>
    <groupId>com.github.wxpaygroupId>
    <artifactId>wxpay-sdkartifactId>
    <version>${wxpay-sdk.version}version>
dependency>

支付宝支付

<sdk-alipay-starter.version>3.7.4.ALLsdk-alipay-starter.version>
<dependency>
    <groupId>net.guerlabgroupId>
    <artifactId>alipay-sdk-javaartifactId>
    <version>${sdk-alipay-starter.version}version>
dependency>

热部署 spring-boot-devtools

<spring-boot-devtools.version>2.1.3.RELEASEspring-boot-devtools>

    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-devtoolsartifactId>
    <optional>trueoptional>
    <scope>truescope>
dependency>

httpclient

<httpclient.version>4.5.7httpclient.version>

<dependency>
    <groupId>org.apache.httpcomponentsgroupId>
    <artifactId>httpclientartifactId>
dependency>

joda-time

用于替换JDK日期处理的日期和时间库


<joda-time.version>2.10.1joda-time.version>

<dependency>
    <groupId>joda-timegroupId>
    <artifactId>joda-timeartifactId>
    <version>${joda-time.version}version>
dependency>

接口文档 springfox-swagger2


<dependency>
    <groupId>io.springfoxgroupId>
    <artifactId>springfox-swagger2artifactId>
    <version>2.9.2version>
dependency>
<dependency>
    <groupId>io.springfoxgroupId>
    <artifactId>springfox-swagger-uiartifactId>
    <version>2.9.2version>
dependency>

<dependency>
    <groupId>com.github.xiaoymingroupId>
    <artifactId>swagger-bootstrap-uiartifactId>
    <version>1.9.6version>
dependency>

在这里插入图片描述

插件

spring boot打包插件,主要将spring boot应用打包成jar文件或者war文件

 
     <plugin> 
      <groupId>org.springframework.bootgroupId> 
      <artifactId>spring-boot-maven-pluginartifactId> 
     plugin> 

你可能感兴趣的:(spring,boot,restful,java)