阅读官方文档,官方文档中对于springboot的简单项目搭建的基本解释。
SpringBoot中spring-parent的作用
Spring Boot provides a number of “Starters” that let you add jars to your classpath. Our applications for smoke tests use the
spring-boot-starter-parentin theparentsection of the POM. Thespring-boot-starter-parentis a special starter that provides useful Maven defaults. It also provides adependency-managementsection so that you can omitversiontags for “blessed” dependencies.
- 根据文档的翻译可以简单概括为spring-boot-starter-parent不提供依赖关系。它主要提供maven的一些默认值,一个依赖管理器用于你添加依赖的时候不需要在maven中加version。原文链接
- 注意:其中不提供依赖的意思是,它不提供如start-web这一类的web启动依赖。即spring-boot-starter-parent不是启动程序,它只是提供了管理工具与预设置值
SpringBoot的Plugin
1 | <plugin> |
Plugin有7个features:
Java 1.8 as the default compiler level.
UTF-8 source encoding.
A dependency management section, inherited from the
spring-boot-dependenciesPOM, that manages the versions of common dependencies. This dependency management lets you omit `` tags for those dependencies when used in your own POM.An execution of the
repackagegoal with arepackageexecution id.Sensible resource filtering.
Sensible plugin configuration (Git commit ID, and shade).
Sensible resource filtering for
application.propertiesandapplication.ymlincluding profile-specific files (for example,application-dev.propertiesandapplication-dev.yml)Since the
application.propertiesandapplication.ymlfiles accept Spring style placeholders (${…}), the Maven filtering is changed to use@..@placeholders. (You can override that by setting a Maven property calledresource.delimiter.)
SpringBoot的Plugin有以下7个作用,其中原文如上,下方是个人理解
java8作为默认的编译器UTF-8作为打包时候的编码方式从spring启动依赖项POM继承的依赖项管理部分,用于管理公共依赖项的版本。这种依赖项管理允许您在自己的POM中使用这些依赖项时省略
标记。 不懂啥意思,直译好像是重新打包的时候会伴随一个重新打包的id
SpringBoot中打包时候传递参数给application.yml配置文件,对其进行资源过滤SpringBoot中打包时候修改配置git commit id和shadeSpringBoot中打包时根据需求过滤不同形式的文件类型,如application.propertiesandapplication.yml简单来说就是从maven中的pom.xml传递参数到application.properties时,需要使用@..@引用变量。如果想修改的话,在pom.xml中的properties中通过<resource.delimiter>@<resource.delimiter>进行修改
SpringBoot在POM中配置示例
SpringBoot作为父项目
1 | <xml version="1.0" encoding="UTF-8"?> |
SpringBoot不作为父项目
由于在公司开发的时候可能需要继承公司的父项目,因而无法继承SpringBoot作为父项目。可采用以下形式
1 |
|