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

具体报错如下:

bash 复制代码
[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全是空方法仍然会出现循环引用的报错

typescript 复制代码
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就正常了

typescript 复制代码
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在进行目录解析的时候进行了一些独特的处理 导致有的命名无法正常解析

相关推荐
随遇而安zx8 分钟前
【多线程】---AQS 原理 知识点(设计思想与源码深度解析)
java·多线程·aqs
LXMXHJ12 分钟前
springboot中的线程操作
java·spring boot·后端·线程
敲代码的嘎仔19 分钟前
自己设计了一个兑换码算法:自增ID + Base32转码 + 按位加权签名 + 异或混淆,面试被追问细节时终于不用慌了
java·数据库·mysql·算法·微服务·面试·职场和发展
ynchyong29 分钟前
微信小程序启动顺序遇到的一个坑
前端·微信小程序
用户2333768521831 分钟前
接口卡死排查实录-缺失return的UB死循环
前端·后端
光影少年42 分钟前
如何实现RN 多环境、多渠道打包
前端·react native·react.js
m0_587383001 小时前
外卖CPS系统开发实战:从架构设计到运营落地全指南
java·spring·小程序·架构·需求分析
zhangzeyuaaa1 小时前
Python asyncio 事件循环演进:从手动管理到现代化实践
java·服务器·python
闲坐含香咀翠1 小时前
百万行数据透视表,我是怎么把 Vue 响应式开销砍到零的
前端·vue.js·性能优化
xiaopang1 小时前
小红书小组件(miniwidget)开发实战:单页面viewState切换架构
前端