当前位置: 首页 > news >正文

仙桃企业网站建设货物运输东莞网站建设

仙桃企业网站建设,货物运输东莞网站建设,网站开发实例社区,c2c网站架构前言 前段时间#xff0c;因项目被扫出大量漏洞#xff0c;全是因为依赖版本过低#xff0c;存在高中危漏洞需要升级。正好本来也有规划集群升级#xff0c;因为工作量大迟迟落实不了#xff0c;正好有这次修漏洞的机会#xff0c;升级微服务集群。这篇文章主要记录了本…前言 前段时间因项目被扫出大量漏洞全是因为依赖版本过低存在高中危漏洞需要升级。正好本来也有规划集群升级因为工作量大迟迟落实不了正好有这次修漏洞的机会升级微服务集群。这篇文章主要记录了本人的升级记录遇到的问题解决方法仅供参考。 项目背景 项目微服务技术栈Spring Boot 1.5.x 、Spring Cloud、Kafka、RabbitMq、Mysql、Eureka、Apollo、Nacos。Spring Boot 是1.5.x 版本非常老旧Spring Cloud 版本也早就停更。根据Nacos的兼容情况Spring Boot 的版本为2.6.13但目前最新版是2.7.18由于3.x跟2.x区别较大因此决定使用2.7.18试试Spring Cloud 版本为2021.0.5.0。 升级记录 在xml中加入依赖过期的配置会提示 dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-properties-migrator/artifactIdscoperuntime/scope /dependency1、Loading class com.mysql.jdbc.Driver. This is deprecated. The new driver class is com.mysql.cj.jdbc.Driver’ 需要更新Mysql驱动 2、Caused by: java.lang.IllegalStateException: Could not resolve element type of Iterable type 。。。。。web.bind.annotation.RequestParam java.util.List. Not declared? RequestParam(value Long[]) List projectIds 此类的代码不能再使用 3、spring.rabbitmq.publisher-confirms 过期 4、Canonical names should be kebab-case (‘-’ separated) 不能使用驼峰形式用- 隔开 5、import org.springframework.cloud.netflix.feign 修改为 import org.springframework.cloud.openfeign 6、2.6以后不允许循环依赖 spring:main:# Spring Boot 2.6以后 默认不允许循环依赖allow-circular-references: true#允许bean覆盖allow-bean-definition-overriding: true7、spring.cloud.client.ipAddress 都修改为 spring.cloud.client.ip-address 8、跨域头修改 由原来的修改为 corsConfiguration.setAllowCredentials(true); corsConfiguration.addAllowedOriginPattern(*);9、gateway 升级要注意去掉重复跨域头 spring.cloud.gateway.default-filters[0] DedupeResponseHeaderAccess-Control-Allow-Origin Access-Control-Allow-Credentials, RETAIN_FIRST 10、database配置过期 The use of configuration keys that have been renamed was found in the environment:Property source ApolloBootstrapPropertySources:Key: spring.datasource.dataReplacement: spring.sql.init.data-locationsKey: spring.datasource.platformReplacement: spring.sql.init.platformKey: spring.datasource.schemaReplacement: spring.sql.init.schema-locations修改 sql:init:platform: mysql#执行的sql语句data-locations: classpath:data.sql#执行的建表语句schema-locations: classpath:schema.sql11、Eureka 配置的修改 instance-id: ${spring.cloud.client.ip-address}:${server.port}metadata-map:user-name: ${spring.security.user.name}user-password: ${spring.security.user.password}12、上传配置的修改 spring:servlet:#最大上传大小MBmultipart:max-file-size: 1000MBmax-request-size: 1000MB13、原有zuul适配 org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.choose(Ljava/lang/String;Lorg/springframework/cloud/client/loadbalancer/Request;)Lorg/springframework/cloud/client/ServiceInstance 增加如下Bean Bean public LoadBalancerClient blockingLoadBalancerClient(LoadBalancerClientFactory loadBalancerClientFactory) {return new BlockingLoadBalancerClient(loadBalancerClientFactory); }14、调用接口报NoSuchMethodError: org.springframework.boot.web.servlet.error.ErrorController.getErrorPath 增加如下类 Configuration public class ZuulConfiguration {/*** The path returned by ErrorController.getErrorPath() with Spring Boot 2.5* (and no longer available on Spring Boot 2.5).*/private static final String ERROR_PATH /error;private static final String METHOD lookupHandler;/*** Constructs a new bean post-processor for Zuul.** param routeLocator the route locator.* param zuulController the Zuul controller.* param errorController the error controller.* return the new bean post-processor.*/Beanpublic ZuulPostProcessor zuulPostProcessor(Autowired RouteLocator routeLocator,Autowired ZuulController zuulController,Autowired(required false) ErrorController errorController) {return new ZuulPostProcessor(routeLocator, zuulController, errorController);}private enum LookupHandlerCallbackFilter implements CallbackFilter {INSTANCE;Overridepublic int accept(Method method) {if (METHOD.equals(method.getName())) {return 0;}return 1;}}private enum LookupHandlerMethodInterceptor implements MethodInterceptor {INSTANCE;Overridepublic Object intercept(Object target, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {if (ERROR_PATH.equals(args[0])) {// by entering this branch we avoid the ZuulHandlerMapping.lookupHandler method to trigger the// NoSuchMethodErrorreturn null;}return methodProxy.invokeSuper(target, args);}}private static final class ZuulPostProcessor implements BeanPostProcessor {private final RouteLocator routeLocator;private final ZuulController zuulController;private final boolean hasErrorController;ZuulPostProcessor(RouteLocator routeLocator, ZuulController zuulController, ErrorController errorController) {this.routeLocator routeLocator;this.zuulController zuulController;this.hasErrorController (errorController ! null);}Overridepublic Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {if (hasErrorController (bean instanceof ZuulHandlerMapping)) {Enhancer enhancer new Enhancer();enhancer.setSuperclass(ZuulHandlerMapping.class);enhancer.setCallbackFilter(LookupHandlerCallbackFilter.INSTANCE); // only for lookupHandlerenhancer.setCallbacks(new Callback[] {LookupHandlerMethodInterceptor.INSTANCE, NoOp.INSTANCE});Constructor? ctor ZuulHandlerMapping.class.getConstructors()[0];return enhancer.create(ctor.getParameterTypes(), new Object[] {routeLocator, zuulController});}return bean;}} } 15、负责均衡找不到下游服务的问题 增加如下类 public class RibbonEurekaClientConfig {Autowiredprivate DiscoveryClient discoveryClient;BeanLazypublic IPing ribbonPing() {return new DummyPing();}BeanLazypublic IRule ribbonRule(IClientConfig clientConfig) {AvailabilityFilteringRule rule new AvailabilityFilteringRule();rule.initWithNiwsConfig(clientConfig);return rule;}BeanLazypublic ServerList? ribbonServerList(IClientConfig clientConfig) {return new ServerListServer() {Overridepublic ListServer getInitialListOfServers() {return new ArrayList();}Overridepublic ListServer getUpdatedListOfServers() {ListServer serverList new ArrayList();ListServiceInstance instances discoveryClient.getInstances(clientConfig.getClientName());if (instances ! null instances.size() 0) {return serverList;}for (ServiceInstance instance : instances) {if (instance.isSecure()) {serverList.add(new Server(https, instance.getHost(), instance.getPort()));} else {serverList.add(new Server(http, instance.getHost(), instance.getPort()));}}return serverList;}};}}在Spring Boot 启动类上配置 RibbonClients(defaultConfiguration RibbonEurekaClientConfig.class) 基于Spring Boot 3.1.0 系列文章 Spring Boot 源码阅读初始化环境搭建Spring Boot 框架整体启动流程详解Spring Boot 系统初始化器详解Spring Boot 监听器详解Spring Boot banner详解Spring Boot 属性配置解析Spring Boot 属性加载原理解析Spring Boot 异常报告器解析Spring Boot 3.x 自动配置详解
http://wiki.neutronadmin.com/news/198204/

相关文章:

  • 开题报告旅游网站建设做鞋子出口需要作网站吗
  • 泸州市往建局建设银行网站名称印发网站建设方案
  • 广州建设工程安全质量监督网站电商网站建设思路
  • 微信公众号可以做微网站山西建设执业注册管理中心网站
  • 保定集团网站建设双桥区网站制作
  • 好的模板网站推荐百度账号申诉
  • 网站前期运营策略福建最大的网络公司排名
  • 网站代理 正规备案全景效果图网站
  • cdr做网站怎么导出设计制作建筑模型综合实践教案
  • 网站开发前后端分离是主流吗做网站公司实力排名
  • 什么样的网站空间做电影网站不卡建网站商城有哪些公司
  • 沈阳工务建设集团网站怎么样自学做网站
  • 网站规划与网页设计wordpress外网ip访问不了
  • 网站想做个链接怎么做的大港建站公司
  • 网站开发流程的三个部分网站开发常用的开发工具
  • wordpress安装532windows11优化大师
  • 新手seo网站做什么类型好sq网站推广
  • 北京seo网站优化培训附近电脑培训速成班一个月
  • 一流的常州做网站国家住建网查企业资质
  • 网站seo关键词优化排名网络工程师培训班要多少钱
  • 网站建设前 沟通内容新网站seo方法
  • 阿里云centos7做网站wordpress 抓取时间长
  • 广州建设集团网站网络推广和竞价推广有什么区别
  • 咸宁有做网站的吗网站被惩罚
  • 租外国服务器做的网站要备案吗wordpress文本编辑
  • 网站开发大概要多少钱集团网站建设方案
  • 广东建设工程网站早期做的网站支持现在的网速吗
  • 电商网站建设概念徐州网站制作功能
  • 格尔木建设局网站农村电商网站建设
  • 鼎成中考开卷通有关网站做的电子书哈尔滨 建网站