@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = JeecgSystemApplication.class)
public class SampleTest {
@MockBean
private CodeGenerateDbConfig initCodeGenerateDbConfig;
}@Configuration
public class CodeGenerateDbConfig {
@Bean
public CodeGenerateDbConfig initCodeGenerateDbConfig() {
if(StringUtils.isNotBlank(url)){
CodegenDatasourceConfig.initDbConfig(driverClassName,url, username, password);
}
return null;
}
}错误是:
Caused by: java.lang.IllegalStateException: Unable to register mock bean org.jeecg.config.init.CodeGenerateDbConfig expected a single matching bean to replace but found [codeGenerateDbConfig, initCodeGenerateDbConfig]发布于 2021-11-26 13:31:10
似乎不支持MockBean,因此必须手动指定它
手动指定要注入的类型将正常启动。
@MockBean(classes = {CodeGenerateDbConfig .class})是否要手动指定要注入的类型?
https://stackoverflow.com/questions/70120505
复制相似问题