小编Bok*_*ero的帖子

Nest 无法将 DataSource 解析为依赖项

我在 NestJS 中遇到了依赖关系问题。在启动我的 NestJS 应用程序时,编译器向我抛出以下错误:

[Nest] 16004  - 09.04.2022, 16:14:46   ERROR [ExceptionHandler] Nest can't resolve dependencies of the AccountService (MailingService, ?). Please make sure that the argument DataSource at index [1] is available in the AccountModule context.
Run Code Online (Sandbox Code Playgroud)

有人可以告诉我我做错了什么吗?

这是我的模块:

@Module({
  imports: [],
  providers: [AccountService, MailingService],
  controllers: [AccountController],
  exports: []
})
export class AccountModule {}

@Module({
  imports: [
    TypeOrmModule.forRootAsync({
      useClass: TypeOrmConfigService,
    }),
  ],
})
export class DatabaseModule {}

@Module({
  imports: [
    DatabaseModule,
    ConfigModule.forRoot({
      envFilePath: '.env',
    }),
    ScheduleModule.forRoot(),
    AccountModule,
    AuthModule,
    MailingModule],
  controllers: …
Run Code Online (Sandbox Code Playgroud)

node.js typescript typeorm nestjs

14
推荐指数
5
解决办法
3万
查看次数

如何将枚举列表转换为字符串数组?

我有一个枚举数组,如下所示:

enum CountryEnum {
   MADAGASCAR,
   LESOTHO,
   BAHAMAS,
   TURKEY,
   UAE
}

List<CountryEnum> countryList = new ArrayList<>();
countryList.add(CountryEnum.MADAGASCAR);
countryList.add(CountryEnum.BAHAMAS);
Run Code Online (Sandbox Code Playgroud)

如何将我的转换countryListString[]

我试过这样:

String[] countries = countryList.toArray(String::new);
Run Code Online (Sandbox Code Playgroud)

但它又回到了我ArrayStoreException

java

0
推荐指数
1
解决办法
447
查看次数

标签 统计

java ×1

nestjs ×1

node.js ×1

typeorm ×1

typescript ×1