SpringBoot 项⽬版本升级:从1.5.3升级到2.1.8版本
SpringBoot 项⽬版本升级:从1.5.3升级到2.1.8版本
前⾔简单记录⼀次本⼈在⾃⼰的SpringBoot 项⽬project-template 中,把版本升级到版本时升级的步骤,及遇到的问题。
提升parent 版本号
更改pom ⽂件中parent 的版本号
修改yml ⽂件中的部分配置在1.5版本中,部分配置与2.1版本有些不同
应⽤名及上下⽂
1.5版本
2.1版本
⽂件上传
1.5版本
2.1版本
mysql 连接
1.5版本
2.1版本
redis 配置
1.5版本
2.1版本
启动项⽬遇到的问题
druid-spring-boot-starter 版本过低报异常
当版本为1.1.6时,报异常:
升级为1.1.10版本即可
SpringSecurity 的AuthenticationManager 启动报异常
当报异常:  1.5.3  2.1.8  <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
<relativePath />
</parent>server:
application-display-name: ProjectTemplate-Web
context-path: /project
server:
servlet:
application-display-name: ProjectTemplate-Web
spring framework版本context-path: /project
spring:
http:
multipart:
location: E:/dev/Project/work/project_data/projettemplate/temp/dev  #⽂件临时⽬录
max-request-size: 40MB
max-file-size: 40MB
spring:
servlet:
multipart:
location: E:/dev/Project/work/project_data/projettemplate/temp/dev # ⽂件临时⽬录
max-request-size: 40MB
max-file-size: 40MB
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: sql.cj.jdbc.Driver
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: sql.cj.jdbc.Driver
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
spring:
redis:  # REDIS (RedisProperties)
database: 0
host: 127.0.0.1
port: 6379
timeout: 2000
jedis:
pool:
max-idle: 8
max-wait: -1
... ...
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.adata.DataSourcePoolMetadataProvider
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.10</version>
</dependency>
A component required a bean of type 'org.springframework.security.authentication.AuthenticationManager' that could not be found
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/projec
在yml⽂件中添加以下配置即可
spring:
main:
allow-bean-definition-overriding: true
完结,撒花。。。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。