【发布时间】:2022-01-15 11:03:32
【问题描述】:
所以我有一个 Nest 应用程序,却被一个感觉很基本的问题困住了。
我需要在 PlaceService 中使用 PlaceVerificationRequestService 但无法正确注入它而不会收到以下错误:
Nest 无法解析 PlaceService 的依赖项(PlaceRepository、ClientService、?)。请确保索引 [2] 处的参数依赖项在 PlaceModule 上下文中可用。
我的方法是遵循与将 ClientService 导入和注入到 PlaceService 时相同的样式/em> 但它仍然不起作用,我不知道为什么。
这是我的代码。
place.module.ts
@Module({
imports: [
MikroOrmModule.forFeature({
entities: [Place, Client, PlaceVerificationRequest],
}),
],
providers: [PlaceService, ClientService, PlaceVerificationRequestService],
controllers: [PlaceController],
exports: [PlaceService],
})
place-verification-request.module.ts
@Module({
imports: [
MikroOrmModule.forFeature({
entities: [PlaceVerificationRequest, Client, Place],
}),
],
providers: [PlaceVerificationRequestService, ClientService, PlaceService],
controllers: [PlaceVerificationRequestController],
exports: [PlaceVerificationRequestService],
})
place.service.ts
@Injectable()
export class PlaceService {
constructor(
@InjectRepository(Place)
private readonly placeRepo: EntityRepository<Place>,
private readonly clientService: ClientService,
private readonly reqService: PlaceVerificationRequestService,
) {}
感觉就像我错过了一些就在我鼻子前面的东西,因为它感觉非常基本,但我似乎无法发现它。任何有线索的人?谢谢
【问题讨论】:
标签: javascript nestjs mikro-orm