Spring boot升级到2.3.2.Release和Spring framework升级到5.28.Release踩过的坑
目录
1. 利用下面方法启动spring boot 项目是系统参数不生效
2. org.drools.template.parser.DecisionTableParseException: Failed to open Excel stream, please check that the content is xls97 format.
3. java.lang.NoClassDefFoundError: Lcom/netflix/config/CachedDynamicIntProperty;
4. Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
5. server.context-path 不起作用了
6. 同时使用ORM技术(Hibernate、JPA、JDO)和JDBC技术(Spring JDBC、iBatis)时, TransationManager怎么配
7. Exception processing template "xlsx***": Error resolving template [***], template might not exist
8. The dependencies of some of the beans in the application context form a cycle
9. Log4j2 error- ERROR StatusLogger Unrecognized format specifier
10. Caused by: java.util.ServiceConfigurationError: javax.xml.parsers.SAXParserFactory: Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found
11. 类找不到的问题
12. Jar 包有问题
版本
Library | Current | Upgraded |
Spring Boot | 1.5.19.RELEASE | 2.3.2.RELEASE |
Spring Framework | 4.3.22.RELEASE | 5.2.8.RELEASE |
1. 利用下面方法启动spring boot 项目是系统参数不生效
[02:15:30][Step 2/2] The system property 'syst1' must be defined
相关命令
mvn spring-boot:run -Dsys1=system1, -Dsys2=system2
解决方法:把系统参数现在-Dspring-boot.run.jvmArgument=“....”里面
mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Dsys1=system1, -Dsys2=system2"
2. org.drools.template.parser.DecisionTableParseException: Failed to open Excel stream, please check that the content is xls97 format.
错误信息如下:
Caused by: java.util.zip.ZipException: invalid stored block lengths
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:164) ~[?:1.8.0_51]
at java.util.zip.ZipInputStream.read(ZipInputStream.java:194) ~[?:1.8.0_51]
at org.apache.poi.openxml4j.util.ZipSecureFile$ThresholdInputStream.read(ZipSecureFile.java:168) ~[poi-ooxml-3.13.jar:3.13]
at java.io.FilterInputStream.read(FilterInputStream.java:107) ~[?:1.8.0_51]
at org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource$FakeZipEntry.<init>(ZipInputStreamZipEntrySource.java:130) ~[poi-ooxml-3.13.jar:3.13]
......
at org.drools.compiler.kie.builder.impl.AbstractKieProject.verify(AbstractKieProject.java:64) ~[drools-compiler-6.3.0.Final.jar:6.3.0.Final]
at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildKieProject(KieBuilderImpl.java:229) ~[drools-compiler-6.3.0.Final.jar:6.3.0.Final]
at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.java:197) ~[drools-compiler-6.3.0.Final.jar:6.3.0.Final]
。。。。
Caused by: org.drools.template.parser.DecisionTableParseException: Failed to open Excel stream, please check that the content is xls97 format.
再Maven里加下面代码确保xlsx不用被Maven过滤。如果被Maven过滤的话好像它会改里面的东西。
<resource><directory>src/main/resources</directory><filtering>false</filtering><includes><include>**/*.xlsx</include></includes></resource>
参考资料
Drools: Caused by: java.util.zip.ZipException: invalid stored block lengths – Wevodio
3. java.lang.NoClassDefFoundError: Lcom/netflix/config/CachedDynamicIntProperty;
解决方法:把Archaius-core 更新到0.7.6 version
4. Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
***************************
APPLICATION FAILED TO START
***************************Description:The bean 'redisMessageListenerContainer', defined in class path resource [org/springframework/boot/autoconfigure/session/RedisSessionConfiguration$SpringBootRedisHttpSessionConfiguration.class], could not be registered. A bean with that name has already been defined in com.example.RedisApplication and overriding is disabled.Action:Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
原因
spring boot 2.1 之后取消了覆盖Bean这一默认特性。原来默认是可以创建多个一样名字的Bean的。
参考资料
https://www.baeldung.com/spring-boot-bean-definition-override-exception
解决方法
加系统参数在application.properties
spring.main.allow-bean-definition-overriding=true
5. server.context-path 不起作用了
我配置的 server.context-path=/web
错误信息如下:
但是log 里面看出,cootext path不生效
原因:spring boot2.0 之后。这个配置改名为server.servlet.context-path。
解决方法:改为server.servlet.context-path名字
#server.context-path=/web
server.servlet.context-path=/web
6. 同时使用ORM技术(Hibernate、JPA、JDO)和JDBC技术(Spring JDBC、iBatis)时, TransationManager怎么配
由于前者的会话(Session)是对后者连接(Connection)的封装,Spring会“足够智能地”在同一个事务线程让前者的会话封装后者的连接。所以,我们只要直接采用前者的事务管理器就可以了。表10-1给出了混合数据访问技术框架所对应的事务管理器。
序 号 | 混合数据访问技术框架 | 事务管理器 |
1 | Hibernate+ Spring JDBC或iBatis | org.springframework.orm.hibernate5.HibernateTransactionManager |
2 | JPA+Spring JDBC或iBatis | org.springframework.orm.jpa.JpaTransactionManager |
3 | JDO+Spring JDBC或iBatis | org.springframework.orm.jdo.JdoTransactionManager |
例如: 你的项目有配有HibernateTransactionManager,也有MyBatis的DataSourceTransactionManager。直接使用HibernateTransactionManager就可以了。
@Beanpublic HibernateTransactionManager transactionManager(@Qualifier("hibernateSessionFactory") SessionFactory sessionFactory){HibernateTransactionManager htm = new HibernateTransactionManager();htm.setSessionFactory(sessionFactory);return htm;}// @Bean
// public DataSourceTransactionManager transactionManager(@Autowired @Qualifier("dataSource") DataSource dataSource) {
// DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(dataSource);
// return transactionManager;
// }
7. Exception processing template "xlsx***": Error resolving template [***], template might not exist
错误信息如下:
[http-nio-8099-exec-1](org.thymeleaf.TemplateEngine:1136) - [THYMELEAF][http-nio-8099-exec-1] Exception processing template "userInformation": Error resolving template [userInformation], template might not exist or might not be accessible by any of the configured Template Resolvers
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [userInformation], template might not exist or might not be accessible by any of the configured Template Resolvers
at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869) ~[thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE]
at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:607) ~[thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE]
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098) ~[thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE]
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072) ~[thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE]
at org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:362) ~[thymeleaf-spring5-3.0.11.RELEASE.jar:3.0.11.RELEASE]
at org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:189) ~[thymeleaf-spring5-3.0.11.RELEASE.jar:3.0.11.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1373) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1118) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1057) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:626) ~[tomcat-embed-core-9.0.37.jar:4.0.FR]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:733) ~[tomcat-embed-core-9.0.37.jar:4.0.FR]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.37.jar:9.0.37]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.37.jar:9.0.37
相关代码:
@Controller
public class UserInformationController {@RequestMapping(method = RequestMethod.GET, value = "/userInformation")public ModelAndView getUserInformation(ModelMap model) {List<User> users= ....model.addAttribute("users", users);return "userInformationReport"}
}@Component("userInformationReport")
public class XlsxStreamingView extends AbstractXlsxStreamingView {
@Overrideprotected void buildExcelDocument(Map<String, Object> model, Workbook workbook, HttpServletRequest request,HttpServletResponse response) throws Exception {List<User> users= = model.get("users");.....// POI related code.. }
}
可以看到这里GetUserInformation方法的返回值是userInformationReport,原来是spring可以智能的调用下面那个类,但是现在不行了。
解决方法
import org.springframework.web.servlet.ModelAndView;
import org.springframework.ui.ModelMap;@Controller
public class UserInformationController {@Autowiredprivate XlsxStreamingView XlsxStreamingView;@RequestMapping(method = RequestMethod.GET, value = "/userInformation")public ModelAndView getUserInformation(ModelMap model) {List<User> users= ....model.addAttribute("users", users);return new ModelAndView(XlsxStreamingView, model);}
}
8. The dependencies of some of the beans in the application context form a cycle
Description:The dependencies of some of the beans in the application context form a cycle:userController (field private xxx.user.service.userWorkflowService xxx.user.controller.userController.userService)↓userProcessorConfig↓xxx.core.workflow.TestWorkflowConfiguration#0 (field private xxx.Test.service.TestDataService xxx.core.workflow.TestWorkflowConfiguration.pendingTestDataService)
┌─────┐
| xxx.Test.TestConfiguration#0
↑ ↓
| xxx.Test.util.ATestRuleConfiguration#0 (field private xxx.Test.TestConfiguration xxx.Test.util.ATestRuleConfiguration.TestConfiguration)
└─────┘Action:Relying upon circular references is discouraged and they are prohibited by default. Update your application to remove the dependency cycle between beans. As a last resort, it may be possible to break the cycle automatically by setting spring.main.allow-circular-references to true.
解决方法:
spring.main.allow-circular-references=true
9. Log4j2 error- ERROR StatusLogger Unrecognized format specifier
错误信息:
ERROR StatusLogger Unrecognized format specifier [d]
ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [thread]
ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [level]
ERROR StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [logger]
ERROR StatusLogger Unrecognized conversion specifier [logger] starting at position 47 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [msg]
ERROR StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [n]
ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.
ERROR StatusLogger Reconfiguration failed: No configuration found for '135fbaa4' at 'null' in 'null'
相关代码- pom.xml
<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-shade-plugin</artifactId> <executions><execution><phase>package</phase><goals><goal>shade</goal></goals><configuration><finalName>your-component-name</finalName></configuration></execution></executions></plugin>
解决方法:
打包的时候去掉Log4j2Plugins.dat 文件。
<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-shade-plugin</artifactId> <executions><execution><phase>package</phase><goals><goal>shade</goal></goals><configuration><finalName>your-component-name</finalName><filters><filter><artifact>*:*</artifact><excludes><exclude>**/Log4j2Plugins.dat</exclude> </excludes></filter></filters></configuration></execution></executions></plugin>
参考资料:
java - log4j2 ERROR StatusLogger Unrecognized conversion specifier - Stack Overflow
10. Caused by: java.util.ServiceConfigurationError: javax.xml.parsers.SAXParserFactory: Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found
错误信息:
Caused by: java.lang.RuntimeException: Provider for class javax.xml.parsers.SAXParserFactory cannot be createdat javax.xml.parsers.FactoryFinder.findServiceProvider(FactoryFinder.java:308) ~[?:1.8.0_311]at javax.xml.parsers.FactoryFinder.find(FactoryFinder.java:267) ~[?:1.8.0_311]at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:127) ~[?:1.8.0_311]at org.appformer.maven.support.MinimalPomParser.parse(MinimalPomParser.java:53) ~[kie-soup-maven-support-7.35.0.Final.jar!/:7.35.0.Final]at org.appformer.maven.support.PomModel$DefaultPomModelGenerator.parse(PomModel.java:136) ~[kie-soup-maven-support-7.35.0.Final.jar!/:7.35.0.Final]at org.appformer.maven.support.PomModel$Parser.parse(PomModel.java:110) ~[kie-soup-maven-support-7.35.0.Final.jar!/:7.35.0.Final]at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildPomModel(KieBuilderImpl.java:590) ~[drools-compiler-7.35.0.Final.jar!/:7.35.0.Final]at org.drools.compiler.kie.builder.impl.KieBuilderImpl.init(KieBuilderImpl.java:154) ~[drools-compiler-7.35.0.Final.jar!/:7.35.0.Final]at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.java:220) ~[drools-compiler-7.35.0.Final.jar!/:7.35.0.Final]at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.java:194) ~[drools-compiler-7.35.0.Final.jar!/:7.35.0.Final]
...
Caused by: java.util.ServiceConfigurationError: javax.xml.parsers.SAXParserFactory: Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not foundat java.util.ServiceLoader.fail(ServiceLoader.java:239) ~[?:1.8.0_311]at java.util.ServiceLoader.access$300(ServiceLoader.java:185) ~[?:1.8.0_311]at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:372) ~[?:1.8.0_311]at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404) ~[?:1.8.0_311]
...
解决方法:
加xercesImpl包
<dependency><groupId>xerces</groupId><artifactId>xercesImpl</artifactId><version>2.12.0</version></dependency>
11. 类找不到的问题
Old | New |
org.springframework.boot.context.embedded. tomcat.TomcatEmbeddedServletContainerFactory |
org.springframework.boot.web.embedded. tomcat.TomcatServletWebServerFactory |
org.springframework.boot.context.embedded .tomcat.TomcatEmbeddedServletContainer |
org.springframework.boot.web.embedded .tomcat.TomcatWebServer |
12. Jar 包有问题
Error | Solution |
Caused by: java.io.FileNotFoundException: class path resource [org/springframework/boot/autoconfigure/web/ ServerPropertiesAutoConfiguration.class] cannot be opened because it does not existatorg.springframework.core.io. ClassPathResource.getInputStream (ClassPathResource.java:180) ~[spring-core-5.2.8.RELEASE.jar:5.2.8.RELEASE] at org.springframework.core.type.classreading.SimpleMetadataReader. getClassReader (SimpleMetadataReader.java:55) ~[spring-core-5.2.8.RELEASE.jar:5.2.8.RELEASE] |
Spring-cloud-netflix-core |
Caused by: java.lang.NoSuchMethodError: org.codehaus.stax2.ri.SingletonIterator.create(Ljava/lang/Object; )Lorg/codehaus /stax2/ri/SingletonIterator; |
<dependency> <groupId>org.codehaus.woodstox</groupId> <artifactId>stax2-api</artifactId> <version>4.2</version> </dependency> |
The following method did not exist: javax.validation.spi.ConfigurationState.getParameterNameProvider() Ljavax/validation/ParameterNameProvider; The method's class, javax.validation.spi.ConfigurationState, is available from the following locations: jar:file:***/javax/validation/validation-api/1.0.0.GA/validation-api-1.0.0.GA.jar!/javax/validation/spi/ConfigurationState.class jar:file:**/repository/jakarta/validation/jakarta.validation-api/2.0.2/jakarta.validation-api-2.0.2.jar!/javax/validation/spi/ConfigurationState.class The class hierarchy was loaded from the following locations: |
移掉 validation-api/1.0.0.GA jar |
What is Spring MVC: @Controllers & @RestControllers
相关系列博客
Hibernate升级到5.4.18.final的过程踩过的坑_keeppractice的博客-CSDN博客
Spring boot admin 升级到2.3.1 遇到的问题总结_keeppractice的博客-CSDN博客
[错误总结]升级spring-boot->2.6.2|hiberate->5.4.33.Final|spring cloud->2021.0.0 |spring admin->2.4.1
Spring boot升级到2.3.2.Release和Spring framework升级到5.28.Release踩过的坑相关推荐
- 17、Spring Boot普通类调用bean【从零开始学Spring Boot】
转载:http://blog.csdn.net/linxingliang/article/details/52013017 我们知道如果我们要在一个类使用spring提供的bean对象,我们需要把这个 ...
- Spring Boot 2.0(四):使用 Docker 部署 Spring Boot
Docker 技术发展为微服务落地提供了更加便利的环境,使用 Docker 部署 Spring Boot 其实非常简单,这篇文章我们就来简单学习下. 首先构建一个简单的 Spring Boot 项目, ...
- Spring Boot干货系列:(十二)Spring Boot使用单元测试 | 嘟嘟独立博客
原文地址 2017-12-28 开启阅读模式 Spring Boot干货系列:(十二)Spring Boot使用单元测试 Spring Boot干货系列 Spring Boot 前言 这次来介绍下Sp ...
- SpringBoot 系列教程(五十):Spring Boot 1.X生命周期已结束 ,Spring Boot 2.X 走向舞台中心
Spring Boot 1.x 生命周期已结束 2019年8月6日,Spring 官方在其博客宣布,Spring Boot 1.x 停止维护,Spring Boot 1.x 生命周期正式结束. 官方宣 ...
- Spring Boot发布2.6.2、2.5.8:升级log4j2到2.17.0
12月22日,Spring官方发布了Spring Boot 2.5.8(包括46个错误修复.文档改进和依赖项升级)和2.6.2(包括55个错误修复.文档改进和依赖项升级). 这两个版本均为缺陷修复版本 ...
- spring Boot 2 基础篇 。内含 整合一个spring boot 的 小案例
目录 springBoot2基础篇 前言与开发环境 一.快速创建Boot项目 1.使用spring提供的快速构建 2.基于maven的手动构建 3.在Idea中隐藏指定文件/文件夹 二.SpringB ...
- 1. spring boot起步之Hello World【从零开始学Spring Boot】
转载:http://blog.csdn.net/linxingliang/article/details/51582286 1.1 介绍 自从structs2出现上次的漏洞以后,对spring的关注度 ...
- spring boot 邮件端口_1 分钟教会你用 Spring Boot 发邮件
Spring Boot 提供了一个发送邮件的简单抽象,使用的是下面这个接口. org.springframework.mail.javamail.JavaMailSender Spring Boot ...
- spring boot 配置网关时404错误_网关Spring Cloud Gateway科普
Spring Cloud Gateway是在Spring生态系统之上构建的API网关服务,它旨在提供一种简单而有效的方式来对API进行路由,以及提供一些强大的过滤器功能, 例如:熔断.限流.重试等. ...
- spring boot mybatis 整合_两大热门框架 Spring 与 Mybatis 如何整合呢?
整合的方式 新建 maven 项目 引入依赖包 配置资源文件 案例实操 新建 maven 项目 新建 maven 项目 spring_mybatis 目录结构如下: 主目录包: com.xxx.d ...
最新文章
- Selection change event Issue is fixed handleListItemPress,SingleSelectMaster
- AngularJS快速入门指南09:SQL
- MySQL5.7 semi-sync replication功能增强
- (7)UART接收verilog与Systemverilog编码
- 【已测】asp留言板,留言转发到手机上
- 松下FP系列PLC以太网通讯
- 【Oracle】数据清洗案例
- 色彩搭配原理与技巧?
- 电容的作用?电容器的作用?
- 终于有人把搜索引擎讲明白了
- Okhttp上传图片
- 实验室管理系统[LIS],powerbuilder12.6开发,SQLSERVER2008数据库
- IDEA解决crtl+space与搜狗输入法冲突
- 统计学习导论 - 基于R的应用 学习笔记1
- 阿里云装mysql选择版本_mysql学习之-三种安装方式与版本介绍
- scapy python_Python中使用Scapy小记
- CenterPoint 学习笔记
- 互联网上要创业 选好域名很重要
- 小区隔音墙生产厂家@初心不改,慢煮岁月
- 基于QT的多媒体播放器