SpringBoot项目版本升级:从1.5.3升级到2.1.8版本
SpringBoot项目版本升级:从1.5.3升级到2.1.8版本
前言
简单记录一次本人在自己的SpringBoot项目project-template中,把
1.5.3版本升级到2.1.8版本时升级的步骤,及遇到的问题。
提升parent版本号
更改pom文件中parent的版本号
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
<relativePath />
</parent>
修改yml文件中的部分配置
在1.5版本中,部分配置与2.1版本有些不同
应用名及上下文
1.5版本
server:
application-display-name: ProjectTemplate-Web
context-path: /project
2.1版本
server:
servlet:
application-display-name: ProjectTemplate-Web
context-path: /project
文件上传
1.5版本
spring:
http:
multipart:
location: E:/dev/Project/work/project_data/projettemplate/temp/dev #文件临时目录
max-request-size: 40MB
max-file-size: 40MB
2.1版本
spring:
servlet:
multipart:
location: E:/dev/Project/work/project_data/projettemplate/temp/dev # 文件临时目录
max-request-size: 40MB
max-file-size: 40MB
mysql连接
1.5版本
spring:
datasource:
url: jdbc:mysql://localhost:3306/projettemplate?useUnicode=true&useSSL=false&characterEncoding=utf-8&autoReconnect=true&serverTimezone=GMT
username: root
password: root
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
2.1版本
spring:
datasource:
druid:
url: jdbc:mysql://localhost:3306/projettemplate?useUnicode=true&useSSL=false&characterEncoding=utf-8&autoReconnect=true&serverTimezone=GMT
username: root
password: root
db-type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
redis配置
1.5版本
spring:
redis: # REDIS (RedisProperties)
database: 0
host: 127.0.0.1
port: 6379
timeout: 2000
pool:
max-active: 8
max-wait: -1
max-idle: 8
min-idle: 0
2.1版本
spring:
redis: # REDIS (RedisProperties)
database: 0
host: 127.0.0.1
port: 6379
timeout: 2000
jedis:
pool:
max-idle: 8
max-wait: -1
启动项目遇到的问题
druid-spring-boot-starter版本过低报异常
当版本为1.1.6时,报异常:
... ...
Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]
... ...
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/autoconfigure/jdbc/metadata/DataSourcePoolMetadataProvider
... ...
java.lang.IllegalStateException: Failed to introspect Class [com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]
... ...
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/autoconfigure/jdbc/metadata/DataSourcePoolMetadataProvider
... ...
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.autoconfigure.jdbc.metadata.DataSourcePoolMetadataProvider
升级为1.1.10版本即可
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.10</version>
</dependency>
SpringSecurity的AuthenticationManager启动报异常
当报异常:
A component required a bean of type 'org.springframework.security.authentication.AuthenticationManager' that could not be found
在SpringSecurity文件中重写即可
@Bean(name = BeanIds.AUTHENTICATION_MANAGER)
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
其他
当报以下异常:
The bean 'userDetailsServiceImpl', defined in class path resource [com/itmacy/dev/auth/security/SecurityConfig.class], could not be registered. A bean with that name has already been defined in file [/Users/chenmeixuan/macy/dev/project/study/webBack/project-template/target/project-template-1.0.0-SNAPSHOT_20200215-1336/classes/com/itmacy/dev/auth/security/UserDetailsServiceImpl.class] and overriding is disabled.
在yml文件中添加以下配置即可
spring:
main:
allow-bean-definition-overriding: true
完结,撒花。。。
SpringBoot项目版本升级:从1.5.3升级到2.1.8版本的更多相关文章
- SpringBoot项目使用Nacos作为配置中心
前置条件:jdk.SpringBoot项目.Nacos.Linux服务器(可无) 具体版本:jdk11.SpringBoot 2.3.5.RELEASE.Nacos 2.0.3.Centos 6 目标 ...
- 基 vue-element-admin升级的Vue3 +TS +Element-Plus 版本的后端管理前端解决方案 vue3-element-admin 正式对外发布,有来开源组织又一精心力作,毫无保留开放从0到1构建过程
项目简介 vue3-element-admin 是基于 vue-element-admin 升级的 Vue3 + Element Plus 版本的后台管理前端解决方案,是 有来技术团队 继 youla ...
- SpringMVC Web项目升级为Springboot项目(一)
一.项目改为Springboot项目 1.将pom中所有spring相关依赖删除,添加spring-boot-starter及spring-boot-starter-web(项目中可能有其他sprin ...
- spring-boot 项目整合logback
使用spring-boot项目中添加日志输出,java的日志输出一共有两个大的方案log4j/log4j2 ,logback.log4j2算是对log4j的一个升级版本. 常规做法是引入slf4j作为 ...
- springboot项目部署到独立tomcat的爬坑集锦
目录 集锦一:普通的springboot项目直接部署jar包 集锦二:springboot项目不能直接打war包部署 集锦三:因为tomcat版本问题导致的lombok插件报错:Invalid byt ...
- 怒改springMVC项目为springBoot项目
背景:公司最近在做项目升级,融合所有项目,但是目前使用的一个系统还是最原始的框架 springMVC+spring+mybatis ,前端还是jsp,easyui(技术老的掉牙),终于出手了,结果.. ...
- Springboot项目报错【java.base/jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to java.base/java.net.URLClassLoader】
1.发生问题: 升级了JDK9,发现原先的springboot项目起不来了,以为是maven中jdk配置有问题. 于是在pom中添加了 <plugin> <groupId>or ...
- docker 运行jenkins及vue项目与springboot项目(三.jenkins的使用及自动打包vue项目)
docker 运行jenkins及vue项目与springboot项目: 一.安装docker 二.docker运行jenkins为自动打包运行做准备 三.jenkins的使用及自动打包vue项目 四 ...
- Gitlab-runner+Docker自动部署SpringBoot项目
本文基于Gitlab CI/CD及Docker快速实现项目的自动部署. 注意:本文较长,浏览需要12分钟左右. 1.环境要求 以下服务器的操作系统均为Centos7 服务器A:Gitlab 服务器B: ...
随机推荐
- AcWing 244. 谜一样的牛|树状数组
传送门 题目描述 有n头奶牛,已知它们的身高为 1~n 且各不相同,但不知道每头奶牛的具体身高. 现在这n头奶牛站成一列,已知第i头牛前面有Ai头牛比它低,求每头奶牛的身高. 输入格式 第1行:输入整 ...
- Go Web 编程之 Hello World
概述 计划写一个讲 Go Web 编程的系列文章.从基于 net/http 包编写 Go Web 程序开始,讲述处理器,请求,响应等基础知识.然后到框架的使用.中间会穿插一些源码的分析.最后做一个实战 ...
- python 条件判断的三元表达式
示例:求两数中最大者 在JavaScript中代码如下: x = 1; y = 2; console.log(x > y ? x : y) 在python中代码如下: # 条件为真时的返回结果 ...
- C++数值计算
1.序 (1)程序设计分两种: 1.结构化设计(面向过程)——分解算法为模块,将算法的步骤分解为模块. 2.面向对象程序设计——主要是“类”与“对象”. (2)进制的转换 1.二进制转十进制 整数部分 ...
- 毒瘤养成记1: 如何卡hash
各位毒瘤大家好, 最近模拟赛考了一道trie+主席树好题, 但大家都用hash水过了这道题(包括我), 为了测试一下新搭建的HEAT OJ的hack功能, 我将继续扮演毒瘤的角色, 用毒瘤的艺术形象努 ...
- Qt Installer Framework翻译(0)
本人主攻C++和Qt. 以前一直看人家的博客,找资料学习.今天我也终于开博客啦. 最近在研究Qt install framework(IFW)应用程序安装框架. google也没发现有正儿八经的官方文 ...
- python __init__()类构造方法
构造方法用于创建对象时使用,每当创建一个类的实例对象时,python解释器都会自动调用它. class Person: def __init__(self): print("调用构造方法&q ...
- c# 三种计算程序运行时间的方法
三种计算c#程序运行时间的方法第一种:利用 System.DateTime.Now // example1: System.DateTime.Now method DateTime dt1 = Sys ...
- AMD R5 2400G插帧教程
最近买的小主机带的是AMD R5 2400G显卡,支持AMD的插帧技术,Sandeepin肯定要体验一把效果. BlueskyFRC 按照网上的教程配置,似乎2400G显卡驱动里没有AMD Fluid ...
- C#反射与特性(四):实例化类型
目录 1,实例化类型 1.1 Activator.CreateInstance() 1.2 ConstructorInfo.Invoke() 2,实例化委托 3,实例化泛型类型 3.1 实例化泛型 3 ...