我在 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) 我有一个枚举数组,如下所示:
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)
如何将我的转换countryList成String[]?
我试过这样:
String[] countries = countryList.toArray(String::new);
Run Code Online (Sandbox Code Playgroud)
但它又回到了我ArrayStoreException。