谷粒商城实战笔记-包依赖踩坑

一, java.lang.ClassNotFoundException: org.springframework.boot.context.properties.ConfigurationBeanFactoryMetadata

ClassNotFoundException类似错误,都是依赖问题,特别是模块比较多,有模块相互依赖、父子依赖,容易出现包版本不对、包冲突等问题。

这次出现的问题主要是product模块依赖common模块,而不是common模块的子模块,所以common模块的dependencyManagementproduct模块不生效,导致版本问题。

dependencyManagement移到父pom文件中即可。

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configurationPropertiesBeans' defined in class path resource [org/springframework/cloud/autoconfigure/ConfigurationPropertiesRebinderAutoConfiguration.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.cloud.context.properties.ConfigurationPropertiesBeans] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@2b193f2d]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:597) ~[spring-beans-5.3.18.jar:5.3.18]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.18.jar:5.3.18]at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.18.jar:5.3.18]at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.18.jar:5.3.18]at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.18.jar:5.3.18]at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213) ~[spring-beans-5.3.18.jar:5.3.18]at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:270) ~[spring-context-5.3.18.jar:5.3.18]at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:762) ~[spring-context-5.3.18.jar:5.3.18]at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:567) ~[spring-context-5.3.18.jar:5.3.18]at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740) ~[spring-boot-2.6.6.jar:2.6.6]at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415) ~[spring-boot-2.6.6.jar:2.6.6]at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) ~[spring-boot-2.6.6.jar:2.6.6]at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:164) ~[spring-boot-2.6.6.jar:2.6.6]at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:206) ~[spring-cloud-context-2.2.1.RELEASE.jar:2.2.1.RELEASE]at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:117) ~[spring-cloud-context-2.2.1.RELEASE.jar:2.2.1.RELEASE]at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:74) ~[spring-cloud-context-2.2.1.RELEASE.jar:2.2.1.RELEASE]at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[spring-context-5.3.18.jar:5.3.18]at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[spring-context-5.3.18.jar:5.3.18]at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[spring-context-5.3.18.jar:5.3.18]at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131) ~[spring-context-5.3.18.jar:5.3.18]at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:85) ~[spring-boot-2.6.6.jar:2.6.6]at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:66) ~[spring-boot-2.6.6.jar:2.6.6]at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) ~[na:na]at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:120) ~[spring-boot-2.6.6.jar:2.6.6]at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:114) ~[spring-boot-2.6.6.jar:2.6.6]at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:65) ~[spring-boot-2.6.6.jar:2.6.6]at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:339) ~[spring-boot-2.6.6.jar:2.6.6]at org.springframework.boot.SpringApplication.run(SpringApplication.java:297) ~[spring-boot-2.6.6.jar:2.6.6]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1312) ~[spring-boot-2.6.6.jar:2.6.6]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) ~[spring-boot-2.6.6.jar:2.6.6]at com.atguigu.gulimall.gateway.GulimallGatewayApplication.main(GulimallGatewayApplication.java:13) ~[classes/:na]
Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.cloud.context.properties.ConfigurationPropertiesBeans] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@2b193f2d]at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:485) ~[spring-core-5.3.18.jar:5.3.18]at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:321) ~[spring-core-5.3.18.jar:5.3.18]at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.buildLifecycleMetadata(InitDestroyAnnotationBeanPostProcessor.java:232) ~[spring-beans-5.3.18.jar:5.3.18]at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.findLifecycleMetadata(InitDestroyAnnotationBeanPostProcessor.java:210) ~[spring-beans-5.3.18.jar:5.3.18]at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(InitDestroyAnnotationBeanPostProcessor.java:149) ~[spring-beans-5.3.18.jar:5.3.18]at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(CommonAnnotationBeanPostProcessor.java:305) ~[spring-context-5.3.18.jar:5.3.18]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:1116) ~[spring-beans-5.3.18.jar:5.3.18]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~[spring-beans-5.3.18.jar:5.3.18]... 30 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadataat java.base/java.lang.Class.getDeclaredMethods0(Native Method) ~[na:na]at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3402) ~[na:na]at java.base/java.lang.Class.getDeclaredMethods(Class.java:2504) ~[na:na]at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:467) ~[spring-core-5.3.18.jar:5.3.18]... 37 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.properties.ConfigurationBeanFactoryMetadataat java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[na:na]... 41 common frames omitted

二,Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway.

***************************
APPLICATION FAILED TO START
***************************Description:Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway.Action:Please set spring.main.web-application-type=reactive or remove spring-boot-starter-web dependency.

错误信息 “Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway.” 表明在你的项目中同时存在Spring MVC和Spring Cloud Gateway,而这二者在某些功能上有冲突。Spring Cloud Gateway是一个基于Spring Framework构建的API网关,旨在为微服务架构提供路由、过滤和代理功能。而Spring MVC则是Spring Framework的一部分,用于构建Web应用的MVC层。

问题的关键在于Spring Cloud Gateway的设计是基于WebFlux(响应式编程模型)构建的,而Spring MVC是基于传统的Servlet API和阻塞IO模型。当两者同时存在于类路径中时,它们可能会试图接管HTTP请求处理的控制,导致不兼容或不可预测的行为。

解决方案

在gateway项目pom依赖中的自定义模块依赖使用标签去除spring-boot-starter-web依赖。

    <dependency><groupId>com.atguigu.gulimall</groupId><artifactId>gulimall-common</artifactId><version>1.0-SNAPSHOT</version><exclusions><exclusion><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></exclusion></exclusions></dependency>

三,No servers available for service

配置spring cloud gateway使用端口访问就可以,使用lb:// 就报503

gateway:routes:- id: admin_routeuri: lb://gulimall-adminuri: http://localhost:8080predicates:- Path=/api/**filters:- RewritePath=/api/?(?<segment>.*), /renren-fast/$\{segment}

uri: lb//demo-server 就会出现这个问题,但是 uri: http://localhost:8080却不会No servers available for service

适配 Spring Boot 2.4,Spring Cloud 2021.x 版本及以上的 Spring Cloud Alibaba 版本按从新到旧排列如下表(最新版本用*标记):

Spring Cloud Alibaba VersionSpring Cloud VersionSpring Boot Version
2021.0.5.0*Spring Cloud 2021.0.52.6.13
2021.0.4.0Spring Cloud 2021.0.42.6.11
2021.0.1.0Spring Cloud 2021.0.12.6.3
2021.1Spring Cloud 2020.0.12.4.2

我使用的Spring Boot和Cloud版本如下。

	<properties><spring-boot.version>2.6.13</spring-boot.version><spring-cloud.version>2021.0.5</spring-cloud.version></properties>

对照上表,把Spring Cloud Alibaba的版本2021.0.5.0改为即可。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/49150.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

目标检测的即时演进:在线学习在行动

目标检测的即时演进&#xff1a;在线学习在行动 在线学习&#xff08;Online Learning&#xff09;是一种机器学习范式&#xff0c;它允许模型通过逐步接收数据并实时更新来学习。这种学习方式对于目标检测尤其重要&#xff0c;因为它允许检测系统在不断变化的环境中适应新的或…

【Rust光年纪】探究Rust异步I/O库:高性能网络应用的选择指南

构建高性能网络应用&#xff1a;Rust异步编程库全方位解析 前言 随着互联网的快速发展&#xff0c;构建高性能和可扩展的网络应用程序变得愈发重要。而异步I/O库和异步编程库在这一领域扮演着至关重要的角色。本文将对几种用于Rust语言的异步I/O库和异步编程库进行介绍和比较…

基本聚集函数和case的应用

文章目录 1.基本聚集函数(1)基本聚集函数的介绍(2)使用基本聚集函数的简单例子&#xff08;1&#xff09;查询最大年龄&#xff0c;最小年龄年龄和平均年龄<1>最大年龄<2>最小年龄<3>平均年龄 (2&#xff09;配合上where语句&#xff0c;查询女士的平均年龄(…

挽民族星光,寻家乡特色

2024年7月15日 西安工程大学计算机科学学院“筑梦乡村&#xff0c;携手同行”赴马家乔蒸面进行进一步探索调查。 实践队伍首先来到蒸面馆初步观察&#xff0c;店铺不大客流量却很多&#xff0c;虽忙的不可开交服务态度却格外热情&#xff0c;紧接着上楼参观了蒸面的制作流程与基…

Python polars学习-09 数据框关联与拼接

背景 polars学习系列文章&#xff0c;第9篇 数据框关联与拼接&#xff08;Join 、Concat&#xff09; 该系列文章会分享到github&#xff0c;大家可以去下载jupyter文件&#xff0c;进行参考学习 仓库地址&#xff1a;https://github.com/DataShare-duo/polars_learn 小编运…

2024前端面试真题【手写篇】

求几个数的总和&#xff08;2&#xff0c;3&#xff0c;4&#xff0c;5&#xff0c;6&#xff0c;6&#xff0c;7&#xff0c;7&#xff0c;8&#xff0c;8&#xff0c;8&#xff09; arr.reduce((total, currentVal, currentInd, arr)>{}, initialVal) const arr [2&#…

C++:智能指针 [unique_ptr]

文章目录 0x1 基本使用0x11 get() [ 参照auto_ptr ]0x12 release() [ 参照auto_ptr ]0x13 reset() [ 参照auto_ptr ]0x14 get_deleter() [ 新增 ]0x15 operator bool [ 新增 ]0x16 swap() [ 新增 ]0x2 make_unique函数 [unique_ptr在C11引入&#xff0c;make_unique在C14引入]0…

JAVA笔记十四

十四、集合 1.集合概述 (1)集合是存储其它对象的特殊对象&#xff0c;可以将集合当作一个容器 (2)集合的相关接口和类位于java.util包中 (3)集合中的接口和类是一个整体、一个体系 2.集合接口 接口定义了一组抽象方法&#xff0c;实现该接口的类需要实现这些抽象方法&…

Docker核心技术:Docker原理之Cgroups

云原生学习路线导航页&#xff08;持续更新中&#xff09; 本文是 Docker核心技术 系列文章&#xff1a;Docker原理之Cgroups&#xff0c;其他文章快捷链接如下&#xff1a; 应用架构演进容器技术要解决哪些问题Docker的基本使用Docker是如何实现的 Docker核心技术&#xff1a;…

C++初学者指南-5.标准库(第一部分)--标准库最小/最大算法

C初学者指南-5.标准库(第一部分)–标准库min/max算法 文章目录 C初学者指南-5.标准库(第一部分)--标准库min/max算法minmaxminmaxclamp (C17)min_elementmax_elementminmax_element相关内容 C标准库算法是一块新领域&#xff1f;⇒简短介绍 min min(a, b) → a 如果 a < b则…

Linux_实现UDP网络通信

目录 1、实现服务器的逻辑 1.1 socket 1.2 bind 1.3 recvfrom 1.4 sendto 1.5 服务器代码 2、实现客户端的逻辑 2.1 客户端代码 3、实现通信 结语 前言&#xff1a; 在Linux下&#xff0c;实现传输层协议为UDP的套接字进行网络通信&#xff0c;网络层协议为IPv4&am…

基于Fabric 的区块链测试方法调研与总结

Fabric概述 从应用层视角来看&#xff0c;Hyperledger Fabric为开发人员提供了CLI命令行终端、事件模块、客户端SDK、链码API等接口&#xff0c;为上层应用提供了身份管理、账本管理、交易管理、智能合约管理等区块链服务&#xff0c;具体如下&#xff1a; 身份管理&#xff…

百年传承,味在蒸面

2024年7月15日&#xff0c;西安工程大学赴陕西安康“筑梦乡村&#xff0c;携手同行”暑期社会实践团队前往陕西安康鼓楼西街对非遗美食马国庆蒸面进行实践活动。 早晨七点&#xff0c;实践团队在鼓楼西街路口整装集合前往马国庆蒸面&#xff0c;据实践团队前期资料收集了解到马…

k8s+containerd(kvm版)

k8s&#xff08;Kubernetes&#xff09;是由Gogle开源的容器编排引擎&#xff0c;可以用来管理容器化的应用程序和服务&#xff0c;k 高可用&#xff1a;系统在长时间内持续正常地运行&#xff0c;并不会因为某一个组件或者服务的故障而导致整个系统不可用可扩展性&#xff1a…

【SpringBoot】 jasypt配置文件密码加解密

目前我们对yml配置文件中的密码都是明文显示&#xff0c;显然这不安全&#xff0c;有的程序员离职了以后可能会做一些非法骚操作&#xff0c;所以我们最好要做一个加密&#xff0c;只能让领导架构师或者技术经理知道这个密码。所以这节课就需要来实现一下。 我们可以使用jasypt…

爬虫学习3:爬虫的深度爬取

爬虫的深度爬取和爬取视频的方式 深度爬取豆瓣读书 import time import fake_useragent import requests from lxml import etree head {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 …

陶德:边种田边写代码,3年300万行,一个人写出了“国产大满贯QT”

这是《开发者说》的第12期&#xff0c;本期我们邀请的开发者是陶德&#xff0c;从小在国企矿山里长大&#xff0c;计算机成绩是文科班里最差的一个&#xff0c;毕业两年找不到工作&#xff0c;睡过公园&#xff0c;讨过剩饭&#xff0c;用打魔兽世界的方式磨炼技术&#xff0c;…

.NET 8+Vue2 部署到Window Server

.NET 8Vue2 部署到Window Server 1 配置环境 1.1 下载安装.NET 8 SDK&#xff0c;下载时需注意目标服务器的系统类型&#xff08;64位 or 32位&#xff09; https://dotnet.microsoft.com/zh-cn/download 1.2 下载安装SQL Server数据库&#xff08;服务和管理工具&#xff…

LeetCode 129, 133, 136

文章目录 129. 求根节点到叶节点数字之和题目链接标签思路代码 133. 克隆图题目链接标签思路代码 136. 只出现一次的数字题目链接标签思路代码 129. 求根节点到叶节点数字之和 题目链接 129. 求根节点到叶节点数字之和 标签 树 深度优先搜索 二叉树 思路 由于本题需要 从…