- spring-boot-starter-parent 是一个特殊的starter,它提供了项目相关的默认依赖,使用它之后 ,常用的包依赖可以省去 version 标签。我们会惊奇地发现,我们的工程自动添加了好多好多jar包, 这些 jar包正是开发时需要导入的jar包
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
- 在 pom.xml 添加如下插件后, 将这个工程打成 jar 包后,可直接通过 java -jar 的命令运行.
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
- spring-boot-starter-parent 是当前项目的父级依赖
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
</parent>
<properties>
<hadoop.version>2.6.4</hadoop.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<mybatisplus.spring.boot.version>1.0.5</mybatisplus.spring.boot.version>
<mybatisplus.version>2.1.9</mybatisplus.version>
<mysql.version>5.1.10</mysql.version>
<mssql.version>4.0</mssql.version>
<oracle.version>11.2.0.3</oracle.version>
<druid.version>1.1.9</druid.version>
<quartz.version>2.3.0</quartz.version>
<commons.lang.version>2.6</commons.lang.version>
<commons.fileupload.version>1.2.2</commons.fileupload.version>
<commons.io.version>2.5</commons.io.version>
<commons.codec.version>1.10</commons.codec.version>
<commons.configuration.version>1.10</commons.configuration.version>
<shiro.version>1.3.2</shiro.version>
<jwt.version>0.7.0</jwt.version>
<kaptcha.version>0.0.9</kaptcha.version>
<guava.version>16.0</guava.version>
<swagger.version>2.4.0</swagger.version>
<joda.time.version>2.9.9</joda.time.version>
<fastjson.version>1.2.45</fastjson.version>
<!--wagon plugin 配置 -->
<service-path>/work/ieslab</service-path>
<pack-name>${project.artifactId}-${project.version}.jar</pack-name>
<remote-addr>192.168.1.10:22</remote-addr>
<remote-username>root</remote-username>
<remote-passwd>123456</remote-passwd>
<poi.version>3.15</poi.version>
</properties>
- spring-boot-starter-web 依赖导入了 Web 项目运行所依赖的组件;如 Tomcat / SpringMVC等
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
- spring-boot-starter-test是 Spring Boot 单元测试模块
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
- spring默认使用yml中的配置,但有时候要用传统的xml或properties配置,就需要使用spring-boot-configuration-processor了
<!--导入配置文件处理器,在编写配置文件时就会提示-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
- Spring Boot 采用了 slf4j+logback 的组合形式
//日志记录器
Logger logger = LoggerFactory.getLogger(getClass());
//跟踪运行信息
logger.trace("这是 trace 日志信息!");
//调试信息
logger.debug("这是 debug 日志信息!");
//自定义信息
logger.info("这是 info 日志信息");
//警告信息:如果运行结果是不预期的值,则可以进行警告
logger.warn("这是 warn 日志信息");
//错误信息:出现异常捕获时
logger.error("这是 error 日志信息");
- Thymeleaf 启动器
<!-- thymeleaf 模板启动器 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
- Spring Boot Devtools 热部署依赖
<!--热部署-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
(File -> Settings -> Build, Execution, Deployment -> Compiler -> 勾选 Build project automatically)
- JDBC相关配置
<!--mysql驱动包-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!--jdbc启动器-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
- 整合 Druid 操作步骤
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.12</version>
</dependency>
- 导入 Druid 数据源依赖, 创建后自动会引入 MyBatis 启动器,是由 MyBatis 官方提供的
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatisplus.version}</version>
<exclusions>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
</exclusion>
</exclusions>
</dependency>
- 引入邮件启动器: spring-boot-starter-mail
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>