作为一个开发人员,不要把代码粘过来直接用,最起码你也要知道你粘过来的代码是什么意思吧。下面简单的介绍一下spring boot项目中pom文件中的依赖
1.spring-boot-starter-parent
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
</parent>
该依赖可以从Starter Parent继承以获得一些默认配置,供以下功能:
Java 1.8作为默认编译器级别
UTF-8编码
从spring-boot-dependencies pom继承一些公共依赖的版本号,从而在使用这些依赖时不用配置项
自动resounce filter
自动plugin配置(exec, git)
自动读取配置文件application.properties和application.yml,包括application-dev.properties和application-dev.yml
2.spring-boot-starter-test
作用:测试模块,包括JUnit、Hamcrest、Mockito。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
3.spring-boot-maven-plugin
作用:在添加了该插件之后,当运行“mvn package”进行打包时,会打包成一个可以直接运行的JAR文件,使用"java -jar"命令就可以直接运行
build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
4.spring-boot-starter-web
作用:web的场景,自动帮我们引入了web模块开发需要的相关jar包
包含了嵌入式 tomcat 、 SpringMVC 必要组件
dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
5.spring-boot-starter
作用:Spring Boot的核心启动器,包含了自动配置、日志和YAML
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>