-
Notifications
You must be signed in to change notification settings - Fork 9
faq compatibility
liubao edited this page Apr 16, 2022
·
2 revisions
迁移框架通常都会涉及三方件升级和兼容问题处理。因为早期的框架由于很久没有更新,依赖了很多老的三方件,而迁移的目标框架一般会选择比较稳定、社区持续维护 和发展的版本。
解决三方件冲突有一些通用的策略:比如尽可能使用新版本替换老版本,采用 dependency management 管理依赖等。 可以参考 三方软件版本管理策略及冲突解决 。
- xml-apis版本过低
报错如下:
Caused by: java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
问题原因为xml-apis版本过低,可以在 dependency management 中约定其版本, 如果在 dependency 中直接引用并指定了版本,可以删除版本号。
<dependencyManagement>
<dependencies>
// others
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
// others
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</dependency>
</dependencies>
- Spring升级CrossOrigin行为变化
报错信息如下:
Caused by: java.lang.IllegalArgumentException: When allowCredentials is true, allowedOrigins cannot contain the special value "*" since that cannot be set on the "Access-Control-Allow-Origin" response header. To allow credentials to a set of origins, list them explicitly or consider using "allowedOriginPatterns" instead.
at org.springframework.web.cors.CorsConfiguration.validateAllowCredentials(CorsConfiguration.java:473) ~[spring-web-5.3.9.jar!/:5.3.9]
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$MappingRegistry.register(AbstractHandlerMethodMapping.java:646) ~[spring-webmvc-5.3.9.jar!/:5.3.9]
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.registerHandlerMethod(AbstractHandlerMethodMapping.java:328) ~[spring-webmvc-5.3.9.jar!/:5.3.9]
需要显示的设置CrossOrigin的originPatterns属性,比如:
@CrossOrigin(allowCredentials = "true", allowedHeaders = "*", originPatterns = "*")
- thymeleaf安全加固限制问题
thymeleaf升级后,做了很多安全增强,有些功能不可用, 报错内容:
2021-10-21 01:08:55,655 ERROR TemplateEngine:1136-[THYMELEAF][http-nio-8091-exec-1] Exception processing template "login": An error happened during template parsing (template: "class path resource [template/login.html]")
org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [template/login.html]")
at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:241) ~[thymeleaf-3.0.12.RELEASE.jar!/:3.0.12.RELEASE]
解决方案,详情参考:stackoverflow 和 thymeleaf
- guava版本过低,导致不兼容问题
报错信息:
2021-10-18 12:36:20,072 WARN LocalCache:2290 -Exception thrown during refresh
java.util.concurrent.ExecutionException: java.lang.NoSuchMethodError: com.google.common.util.concurrent.Futures.submit(Ljava/util/concurrent/Callable;Ljava/util/concurrent/Executor;)Lcom/google/common/util/concurrent/ListenableFuture;
,可以在 dependency management 中约定其版本, 如果在 dependency 中直接引用并指定了版本,可以删除版本号。
<dependencyManagement>
<dependencies>
// others
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.0-jre</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
// others
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
</dependencies>
- guava 和 google-connections 包含相同的类
报错信息:
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
com.google.common.cache.CacheBuilder.getKeyStrength(CacheBuilder.java:529)
The following method did not exist: com.google.common.base.Objects.firstNonNull(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
The method's class, com.google.common.base.Objects, is available from the following locations: jar:file:/D:/BASA_maven/com/google/collections/google-collections/1.0/google-collections-1.0.jar!/com/google/common/base/Objects.class jar:file:/D:/BASA_maven/com/google/guava/guava/16.0.1/guava-16.0.1.jar!/com/google/common/base/Objects.class
The class hierarchy was loaded from the following locations:
com.google.common.base.Objects: file:/D:/BASA_maven/com/google/collections/google-collections/1.0/google-collections-1.0.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of com.google.common.base.Objects
解决方案:
删除google-collections依赖,guava使用新版本。google-collections已经很久不维护,不能使用,相关功能已经合并到guava中。
- 微服务开发框架迁移概述
- Spring Cloud Gateway迁移CSE
- Zuul迁移CSE
-
Nacos+Spring Cloud迁移CSE
- 使用migrator完成一键式改造
- migrator改造步骤详细说明
-
Eureka+Spring Cloud迁移CSE
- 使用migrator完成一键式改造
- migrator改造步骤详细说明
-
HSF迁移Spring Cloud
- 使用migrator完成一键式改造
- migrator改造步骤详细说明
-
Dubbo迁移Spring Cloud
- 使用migrator完成一键式改造
- migrator改造步骤详细说明
- 常见问题
- 为migrator项目贡献代码