@ContextConfiguration(classes = ConfigureCustomConfigurationModelProviderTest.class)
public class ConfigureCustomConfigurationModelProviderTest extends AbstractContextTest {
@Bean(name = "smth")
public static ConfigurationModelProvider get() {
return AnnotationConfigurationModelProvider.getInstance();
}
/*...*/
}
我从junit4迁移到junit5后出现此错误。为什么呢?
答案 0 :(得分:2)
您应该将每个bean
移至@Configuration
类,例如TestConfig
:
@Configuration
public class TestConfig {
@Bean(name = "smth")
public static ConfigurationModelProvider get() {
return AnnotationConfigurationModelProvider.getInstance();
}
}
并通过@Import
@Import({TestConfig.class})
@ContextConfiguration(classes = ConfigureCustomConfigurationModelProviderTest.class)
public class ConfigureCustomConfigurationModelProviderTest extends AbstractContextTest {
}