博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Spring Boot开启的2种方式
阅读量:7080 次
发布时间:2019-06-28

本文共 2101 字,大约阅读时间需要 7 分钟。

Spring Boot依赖

使用Spring Boot很简单,先添加基础依赖包,有以下两种方式

1. 继承spring-boot-starter-parent项目

org.springframework.boot
spring-boot-starter-parent
1.5.6.RELEASE

2. 导入spring-boot-dependencies项目依赖

org.springframework.boot
spring-boot-dependencies
1.5.6.RELEASE
pom
import

Spring Boot依赖注意点

1. 属性覆盖只对继承有效

This only works if your Maven project inherits (directly or indirectly) from spring-boot-dependencies. If you have added spring-boot-dependencies in your own dependencyManagement section with <scope>import</scope> you have to redefine the artifact yourself instead of overriding the property.

Spring Boot依赖包里面的组件的版本都是和当前Spring Boot绑定的,如果要修改里面组件的版本,只需要添加如下属性覆盖即可,但这种方式只对继承有效,导入的方式无效。

1.7.25

如果导入的方式要实现版本的升级,达到上面的效果,这样也可以做到,把要升级的组件依赖放到Spring Boot之前。

org.springframework.data
spring-data-releasetrain
Fowler-SR2
import
pom
org.springframework.boot
spring-boot-dependencies
1.5.6.RELEASE
pom
import

Each Spring Boot release is designed and tested against a specific set of third-party dependencies. Overriding versions may cause compatibility issues.

需要注意,要修改Spring Boot的依赖组件版本可能会造成不兼容的问题。

2. 资源文件过滤问题

使用继承Spring Boot时,如果要使用Maven resource filter过滤资源文件时,资源文件里面的占位符为了使${}和Spring Boot区别开来,此时要用@...@包起来,不然无效。另外,@...@占位符在yaml文件编辑器中编译报错,所以使用继承方式有诸多问题,坑要慢慢趟。

推荐:

扫描关注我们的微信公众号,干货每天更新。

image

转载地址:http://lecml.baihongyu.com/

你可能感兴趣的文章
我的友情链接
查看>>
华为Agile Controller-Campus web界面admin管理员密码不对无法登陆
查看>>
遇到多个构造器参数时要考虑用构建器
查看>>
windos 8 虚拟光驱/硬盘技术
查看>>
WLC和汇聚交换机的配置
查看>>
使用python-gitlab的API V4来批量创建projects
查看>>
CLR.Via第三版第二章 生成、打包、部署和管理i应用程序及类型(
查看>>
Play Framework 2.3.x开始
查看>>
rz sz上传下载工具使用指南
查看>>
Spring与Ehcache简单自定义监听器配置
查看>>
关于ha高可用性的安装,ClusterIP和tomcat的配置
查看>>
我的系统我做主-----深度裁剪红帽5.8系统过程演示(只有5M哦)
查看>>
nosql的使用
查看>>
Lync 小技巧-48-Lync 语音邮箱-英文提示-自动助理-中文提示
查看>>
windows系统管理(一)vmware的安装及vmware下windows server 2008系统安装
查看>>
常见iptables策略
查看>>
Yii PHP 框架分析 (一)
查看>>
Docker容器跑Open***
查看>>
Linux 添加用户 并且给用户超级管理员权限
查看>>
HTTP
查看>>