fix(spring): 修复应用启动时因缺少CustomerOrderService Bean导致的依赖注入失败

- 添加了缺失的CustomerOrderService Bean定义
- 修正了Spring容器中服务组件的扫描配置
- 解决了由于构造函数注入引起的启动异常
- 更新了相关日志记录以提高故障排查效率
This commit is contained in:
2025-12-22 15:28:39 +08:00
parent a38af35ac5
commit 502e181db8
2 changed files with 179 additions and 0 deletions

View File

@@ -2740,3 +2740,129 @@ org.springframework.web.servlet.resource.NoResourceFoundException: No static res
2025-12-22 15:06:07.417 [http-nio-8082-exec-2] DEBUG c.mtkj.mtpay.mapper.MtProductLinkMapper.selectList - <== Total: 1
2025-12-22 15:06:07.417 [http-nio-8082-exec-2] DEBUG c.mtkj.mtpay.service.impl.ProductLinkServiceImpl - 找到现有有效链接,链接码: 3582a1dfbb174d84aac9f465b7180b50, 商品ID: 1
2025-12-22 15:06:07.480 [http-nio-8082-exec-2] INFO com.mtkj.mtpay.service.impl.ProductServiceImpl - 获取商品URL成功商品ID: 1, 链接码: 3582a1dfbb174d84aac9f465b7180b50, URL: http://localhost:3000/product/3582a1dfbb174d84aac9f465b7180b50
2025-12-22 15:21:37.797 [Thread-8] INFO org.apache.coyote.http11.Http11NioProtocol - Stopping ProtocolHandler ["http-nio-8082"]
2025-12-22 15:21:38.002 [restartedMain] INFO com.mtkj.mtkjpay.MtkjpayApplication -
╔══════════════════════════════════════════════════════════╗
║ ║
║ MTKJ PAY 支付系统正在启动... ║
║ ║
╚══════════════════════════════════════════════════════════╝
2025-12-22 15:21:38.073 [restartedMain] INFO com.mtkj.mtkjpay.MtkjpayApplication - Starting MtkjpayApplication using Java 17.0.12 with PID 19528 (E:\MTKJPAY\mt-startup\target\classes started by 18969 in E:\MTKJPAY)
2025-12-22 15:21:38.073 [restartedMain] INFO com.mtkj.mtkjpay.MtkjpayApplication - The following 1 profile is active: "dev"
2025-12-22 15:21:38.537 [restartedMain] INFO org.apache.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-8082"]
2025-12-22 15:21:38.538 [restartedMain] INFO org.apache.catalina.core.StandardService - Starting service [Tomcat]
2025-12-22 15:21:38.538 [restartedMain] INFO org.apache.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/10.1.16]
2025-12-22 15:21:38.560 [restartedMain] INFO o.a.c.core.ContainerBase.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext
2025-12-22 15:21:38.582 [restartedMain] INFO com.mtkj.mtpay.config.MyBatisPlusConfig - 初始化MyBatis-Plus分页插件数据库类型: MYSQL
2025-12-22 15:21:38.582 [restartedMain] INFO com.mtkj.mtpay.config.MyBatisPlusConfig - MyBatis-Plus分页插件配置完成
2025-12-22 15:21:38.585 [restartedMain] INFO com.mtkj.mtpay.config.DruidDataSourceConfig - 初始化Druid主数据源
2025-12-22 15:21:38.585 [restartedMain] INFO com.mtkj.mtpay.config.DruidDataSourceConfig - 配置属性 - URL: jdbc:mysql://rm-j6c3u06k2afwn8hxw6o.mysql.rds.aliyuncs.com:3306/mtpay?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai, Username: mtkj2025
2025-12-22 15:21:38.585 [restartedMain] INFO com.mtkj.mtpay.config.DruidDataSourceConfig - Druid主数据源配置完成URL: jdbc:mysql://rm-j6c3u06k2afwn8hxw6o.mysql.rds.aliyuncs.com:3306/mtpay?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
2025-12-22 15:21:38.831 [restartedMain] WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'customerOrderController' defined in file [E:\MTKJPAY\mt-pay\target\classes\com\mtkj\mtpay\controller\CustomerOrderController.class]: Unsatisfied dependency expressed through constructor parameter 0: No qualifying bean of type 'com.mtkj.mtpay.service.CustomerOrderService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2025-12-22 15:21:38.832 [restartedMain] INFO org.apache.catalina.core.StandardService - Stopping service [Tomcat]
2025-12-22 15:21:38.873 [restartedMain] ERROR o.s.b.diagnostics.LoggingFailureAnalysisReporter -
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in com.mtkj.mtpay.controller.CustomerOrderController required a bean of type 'com.mtkj.mtpay.service.CustomerOrderService' that could not be found.
Action:
Consider defining a bean of type 'com.mtkj.mtpay.service.CustomerOrderService' in your configuration.
2025-12-22 15:21:38.874 [restartedMain] ERROR com.mtkj.mtkjpay.MtkjpayApplication -
╔══════════════════════════════════════════════════════════╗
║ ║
║ ❌ MTKJ PAY 支付系统启动失败! ❌ ║
║ ║
╚══════════════════════════════════════════════════════════╝
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'customerOrderController' defined in file [E:\MTKJPAY\mt-pay\target\classes\com\mtkj\mtpay\controller\CustomerOrderController.class]: Unsatisfied dependency expressed through constructor parameter 0: No qualifying bean of type 'com.mtkj.mtpay.service.CustomerOrderService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:802)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:241)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1356)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1193)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:563)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:523)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:325)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:323)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:973)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:946)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:616)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:753)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:455)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:323)
at com.mtkj.mtkjpay.MtkjpayApplication.main(MtkjpayApplication.java:33)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.mtkj.mtpay.service.CustomerOrderService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1878)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1404)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1348)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:911)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:789)
... 22 common frames omitted
2025-12-22 15:21:40.336 [restartedMain] INFO com.mtkj.mtkjpay.MtkjpayApplication -
╔══════════════════════════════════════════════════════════╗
║ ║
║ MTKJ PAY 支付系统正在启动... ║
║ ║
╚══════════════════════════════════════════════════════════╝
2025-12-22 15:21:40.369 [restartedMain] INFO com.mtkj.mtkjpay.MtkjpayApplication - Starting MtkjpayApplication using Java 17.0.12 with PID 19528 (E:\MTKJPAY\mt-startup\target\classes started by 18969 in E:\MTKJPAY)
2025-12-22 15:21:40.369 [restartedMain] INFO com.mtkj.mtkjpay.MtkjpayApplication - The following 1 profile is active: "dev"
2025-12-22 15:21:40.637 [restartedMain] INFO org.apache.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-8082"]
2025-12-22 15:21:40.638 [restartedMain] INFO org.apache.catalina.core.StandardService - Starting service [Tomcat]
2025-12-22 15:21:40.638 [restartedMain] INFO org.apache.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/10.1.16]
2025-12-22 15:21:40.655 [restartedMain] INFO o.a.c.c.ContainerBase.[Tomcat-1].[localhost].[/] - Initializing Spring embedded WebApplicationContext
2025-12-22 15:21:40.669 [restartedMain] INFO com.mtkj.mtpay.config.MyBatisPlusConfig - 初始化MyBatis-Plus分页插件数据库类型: MYSQL
2025-12-22 15:21:40.669 [restartedMain] INFO com.mtkj.mtpay.config.MyBatisPlusConfig - MyBatis-Plus分页插件配置完成
2025-12-22 15:21:40.672 [restartedMain] INFO com.mtkj.mtpay.config.DruidDataSourceConfig - 初始化Druid主数据源
2025-12-22 15:21:40.672 [restartedMain] INFO com.mtkj.mtpay.config.DruidDataSourceConfig - 配置属性 - URL: jdbc:mysql://rm-j6c3u06k2afwn8hxw6o.mysql.rds.aliyuncs.com:3306/mtpay?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai, Username: mtkj2025
2025-12-22 15:21:40.672 [restartedMain] INFO com.mtkj.mtpay.config.DruidDataSourceConfig - Druid主数据源配置完成URL: jdbc:mysql://rm-j6c3u06k2afwn8hxw6o.mysql.rds.aliyuncs.com:3306/mtpay?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
2025-12-22 15:21:40.926 [restartedMain] INFO com.mtkj.mtpay.config.RestClientConfig - 初始化RestClient配置JSON消息转换器
2025-12-22 15:21:40.931 [restartedMain] INFO com.mtkj.mtpay.config.RestClientConfig - RestClient配置完成
2025-12-22 15:21:41.041 [restartedMain] INFO com.mtkj.mtpay.config.WebConfig - 配置跨域访问,路径: /api/**, 允许所有来源
2025-12-22 15:21:41.041 [restartedMain] INFO com.mtkj.mtpay.config.WebConfig - 跨域配置完成
2025-12-22 15:21:41.134 [restartedMain] INFO org.apache.coyote.http11.Http11NioProtocol - Starting ProtocolHandler ["http-nio-8082"]
2025-12-22 15:21:41.143 [restartedMain] INFO com.mtkj.mtkjpay.MtkjpayApplication - Started MtkjpayApplication in 0.803 seconds (process running for 5330.599)
2025-12-22 15:21:41.145 [restartedMain] INFO com.mtkj.mtkjpay.MtkjpayApplication -
╔══════════════════════════════════════════════════════════╗
║ ║
║ ✅ MTKJ PAY 支付系统启动成功! ✅ ║
║ ║
╠══════════════════════════════════════════════════════════╣
║ 应用信息 ║
╠══════════════════════════════════════════════════════════╣
║ 应用名称: {:<45} ║
║ 运行环境: {:<45} ║
║ 服务端口: {:<45} ║
╠══════════════════════════════════════════════════════════╣
║ 访问地址 ║
╠══════════════════════════════════════════════════════════╣
║ 后端服务: {:<45} ║
║ API接口: {:<45} ║
║ Druid监控: {:<45} ║
╠══════════════════════════════════════════════════════════╣
║ 状态: 🟢 服务运行中,可以接收请求 ║
╚══════════════════════════════════════════════════════════╝
2025-12-22 15:21:41.146 [restartedMain] INFO com.mtkj.mtkjpay.MtkjpayApplication -
📌 提示:
- 前端代理地址: http://localhost:3000
- 后端API地址: http://localhost:8082//api
- 图片上传接口: http://localhost:8082//api/product/upload/image
- 商品管理接口: http://localhost:8082//api/product