使用Spring Boot的两种方式
来源:互联网 发布:进化算法和遗传算法 编辑:程序博客网 时间:2024/05/11 09:05
继承spring-boot-starter-parent
如果继承spring-boot-starter-parent,需在pom.xml中加入如下:
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.0.M3</version></parent>
注:在此需要指定Spring Boot的版本号,如果要导入其他的starters,则可省略版本号。
在这种设置情况下,你也可以通过在自己的Pom覆盖一属性值的方式覆盖个别依赖。如,要升级spring data发布版:
<properties> <spring-data-releasetrain.version>Fowler-SR2</spring-data-releasetrain.version></properties>
不继承Spring Boot paren POM
并不是每个人都喜欢继承spring-boot-starter-parent,可能是因为有自己需要使用的企业父项目,或者你仅仅喜欢明确的声明你的所有MAVEN配置。
如果不想继承spring-boot-starter-parent,但想要使用其依赖管理可以以如下的方式使用:
<dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>2.0.0.M3</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies></dependencyManagement>
使用此种方式就能像上面阐述的那样可以在自己项目Pom中改变一个属性的性即可覆盖个别依赖。为了达到这种效果,你需要在spring-boot-dependencies之前添加对应的依赖:
<dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-releasetrain</artifactId> <version>Fowler-SR2</version> <scope>import</scope> <type>pom</type> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>2.0.0.M3</version> <type>pom</type> <scope>import</scope> </denpendency> </dependencies></dependencyManagement>
阅读全文
0 0
- 使用Spring Boot的两种方式
- Spring Boot 注解启动的两种方式
- Spring-boot中读取config配置文件的两种方式
- Spring-boot中读取config配置文件的两种方式
- Spring Boot 注解启动的两种方式
- Spring-boot中读取config配置文件的两种方式
- Spring-boot中读取config配置文件的两种方式
- Spring-boot中读取config配置文件的两种方式
- Spring boot 整合Swagger的两种方式
- Spring MVC的两种使用方式
- Spring MVC Controller基于Annotation的两种使用方式
- spring使用properties属性文件的两种方式
- 3.Spring Boot + Security初步使用(覆盖配置的两种方式 配置类和XML注入以自定义页面为例)
- 使用web.xml方式加载Spring时,获取Spring context的两种方式
- 使用web.xml方式加载Spring时,获取Spring context的两种方式
- Spring Boot的三种启动方式
- Spring Boot开启的2种方式
- spring bean 不使用注入的方式获取的两种方式
- Central Europe Regional Contest 2016 C.Convex Contour
- 系统管理员应该知道的 20 条 Linux 命令
- luoguP1073 最优贸易
- linux下查看多某个IP的寻址路由信息
- C语言之递归篇
- 使用Spring Boot的两种方式
- Activity和Fragment生命周期
- 使用CMake进行android native开发
- 链式队列的基本应用(接上篇)
- 顺序栈
- 如何验证 names(名称), e-mails(邮件), 和 URLs
- 面试题:介绍JS基础数据类型
- 1020. Tree Traversals (25)
- GCC编译ARM篇