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

nestjs目录命名导致的循环引用

具体报错如下:

[Nest] 2024  - 2024/09/02 22:57:02   ERROR [ExceptionHandler] A circular dependency has been detected inside ApplicationModule. Please, make sure that each side of a bidirectional relationships are decorated with "forwardRef()". Note that circular relationships between custom providers (e.g., factories) are not supported since functions cannot be called more than once.
Error: A circular dependency has been detected inside ApplicationModule. Please, make sure that each side of a bidirectional relationships are decorated with "forwardRef()". Note that circular relationships between custom providers (e.g., factories) are not supported since functions cannot be called more than once.

复现方式:尽管U8AppService全是空方法仍然会出现循环引用的报错

import { App } from "@/entities/app.entity";
import { TypeOrmModule } from "@hg/born-typeorm";
import { Module, Injectable } from "@hg/born/common";
import { ApplicationController } from "./controller";
import { U8AppService } from "./Service";@Module({imports: [TypeOrmModule.forFeature([App])],controllers: [ApplicationController],providers: [U8AppService],exports: [U8AppService],
})
export class ApplicationModule { }

修改方法:将目录名从Service改为base就正常了


import { App } from "@/entities/app.entity";
import { TypeOrmModule } from "@hg/born-typeorm";
import { Module, Injectable } from "@hg/born/common";
import { ApplicationController } from "./controller";
import { U8AppService } from "./base";@Module({imports: [TypeOrmModule.forFeature([App])],controllers: [ApplicationController],providers: [U8AppService],exports: [U8AppService],
})
export class ApplicationModule { }

猜测nestjs在进行目录解析的时候进行了一些独特的处理 导致有的命名无法正常解析


http://www.mrgr.cn/news/18408.html

相关文章:

  • C语言操作符详解1(含进制转换,原反补码)
  • 自控原理-传递函数(闭环 扰动 偏差 前馈 复合 顺馈)
  • Linux | 匿名管道和命名管道:进程间通信数据流的桥梁
  • 【13年12月CCF计算机软件能力认证】:出现次数最多的数、ISBN号码、最大的矩形、有趣的数、I‘m stuck!
  • java xml 转json json 转 json对象
  • 当前开发技术的未来发展:趋势、机遇与挑战
  • 当敏捷开发遇上AI
  • scikit-learn:一个强大的机器学习Python库
  • 【硬件知识】从零开始认识GPU
  • 项目管理流程处理策略
  • 《深度学习》OpenCV 图像轮廓检测、轮廓处理及代码演示
  • 800 行开源代码编程助手,命令行版的 Claude Artifacts
  • 史上最全!研究生科研必备科研工具(含AI科研工具),附使用说明和示例
  • java后端开发-Mybatis连接数据库步骤
  • k8s安装test
  • Fabric.js中fabric.Text的深入解析
  • 嵌入式硬件-ARM处理器架构,CPU,SOC片上系统处理器
  • 自己开发完整项目一、登录功能-05(动态权限控制)
  • E1.S接口如何解决SSD过热问题?
  • 运维问题0001:MM模块-MIGO收货报错“消息号 M7036 对于采购订单********无收货可能”