spring - 找不到@SpringBootConfiguration,需要使用@ContextConfiguration 或@SpringBootTest(classes=...)
问题描述
我有这个测试课。当我运行这个时,我收到了这个错误
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@ActiveProfiles(value = "test")
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
public class HealthGaugeMetricsIT {
/**
* MasterHealthMetricsReporter for creating the gauges.
*/
@Autowired
private MasterHealthMetricsReporter masterHealthMetricsReporter;
/**
* Holds meter registry instance.
*/
@Autowired
private MeterRegistry registry;
/**
* Test for creating the vault gauge and testing that it's bound
* correctly.
*/
@Test
public void testVaultGauge ()
{
masterHealthMetricsReporter.bindTo(registry);
final Gauge g = registry.get("encryption.sampleApp.health.vault").gauge();
assertEquals("validating that vault gauge return the correct value",
1.0, g.value(), 0.0);
}
}
由于这个问题,我无法运行这个测试用例。验证包结构,包结构在 src/main/java 和 src/test/java 中是相同的。
解决方案
推荐阅读
- python - 使用 Pandas 计算加权平均值以降低成本
- wordpress - Wordpress 插件 - 使用 AJAX 请求 WPDB
- node.js - 当我尝试从节点 API 获取数据时未定义
- php - Insert data into database if value doesn't exists in specific column
- python - 用于匹配 URL 中的电子邮件的正则表达式
- sql-server - 无法读取 Object.eval [as updateDirectives] 处未定义的属性“Nome”
- ansible - Ansible 动态清单:无法使用 group_vars
- c# - Visual Studio 2019 版本 c# 问题
- python - 用于 3d 数组列表的类似网格的函数
- php - Unable to show modal popup when LDAP authentication failed