通过Spring-cloud从GIT访问xml文件的问题

时间:2016-09-19 19:25:48

标签: spring-boot spring-cloud

为应用程序使用基于Spring的云配置。使用spring-cloud-config-server进行配置测试。

需要从简单的books.xml文件中读取配置

<catalog>
    <book id="bk101">
      <author>Gambardella, Matthew</author>
      <title>XML Developer's Guide</title>
      <genre>Computer</genre>
      <price>44.95</price>
      <publish_date>2000-10-01</publish_date>
      <description>An in-depth look at creating applications with XML.</description>
    </book>
</catalog>

基于以下提交和讨论,可以在Spring云中从GIT读取xml文件中的配置,但是没有可用的测试用例。

此外,在spring-cloud-config-server/src/test/resources/ *中,没有xml文件,spring-cloud-config-server/src/test/java/ *

下没有示例

当JUnits从下面的文件中读取本地存储库时,需要将xml文件推送到spring-cloud-config-server/src/test/resources/config-repo/然后访问它。

@Test
public void addTestNewPush() throws Exception {
    String uri = ConfigServerTestUtils.prepareLocalRepo("config-repo");
    this.context = new SpringApplicationBuilder(TestConfiguration.class).web(false)
                                    .run("--spring.cloud.config.server.git.uri=" + uri);
    EnvironmentRepository repository = this.context.getBean(EnvironmentRepository.class);
    Environment environment = repository.findOne("bar", "staging", "master");
    Git git = Git.open(ResourceUtils.getFile(uri).getAbsoluteFile());
    Path applicationFilePath = Paths.get("C:/Users/sholalkere/Desktop/books.xml");
    git.add().addFilepattern(".").call();
    git.add().addFilepattern("books.xml").call();
    git.commit().setMessage("Updated for pull").call();
    environment = repository.findOne("catalog", "staging", "master");
    assertEquals("catalog",environment.getPropertySources().get(0).getSource().get("catalog"));
}

推送到git不起作用。这有什么不对?

0 个答案:

没有答案