我有以下YAML文件内容:
reports:
reportPaths:
10: \\\\path\\Reports\\
10M: \\\\path\\Reports\\
这是我的报告配置类。我试图将yaml内容读作Map
:
@ConfigurationProperties(prefix="reports")
public class ReportConfiguration {
private Map<String, String> reportPaths;
public Map<String, String> getReportPaths() {
return reportPaths;
}
public void setReportPaths(Map<String, String> reportPaths) {
this.reportPaths = reportPaths;
}
我有以下测试类:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(
loader = AnnotationConfigContextLoader.class,
classes = ReportConfiguration.class)
public class ReportConfigurationLoadTest {
@Autowired
private ReportConfiguration reportConfiguration;
@Test
public void testLoadingOfReportConfigProperties() {
assertNotNull(reportConfiguration);
System.out.println("reportPaths = " + reportConfiguration.getReportPaths());
assertThat(reportConfiguration.getReportPaths(), allOf(
hasEntry("10", "\\\\path\\Reports\\"));
}
}
reportConfiguration.getReportPaths()
返回null的错误是什么?