首页 > 解决方案 > Spring AntPathMatcher 行为

问题描述

在启动时,我们的应用程序正在调用PathMatchingResourcePatternResolver以动态发现类路径上的资源。

在 内org.springframework.core.io.support.PathMatchingResourcePatternResolver.doRetrieveMatchingFiles(String, File, Set<File>),以下情况永远不会成立:

在此处输入图像描述

请注意,我正在从 Eclipse 运行我们的应用程序。

fullPattern我使用和变量中看到的相同值进行了示例测试currPath,并且它起作用了。测试如下:

import org.springframework.util.AntPathMatcher;

public class DummyTest {

   public static void main(String[] args) {

         AntPathMatcher m = new AntPathMatcher();

          String pattern = "C:/temp/target/classes/com/test/dummy/**/myFile.xml";
          String path = "C:/temp/target/classes/com/test/dummy/anotherRep/myFile.xml";

          if(m.match(pattern, path)) {
                System.out.println("match");
           }
           else {
                 System.out.println("doesn't match");
           }
}

}

有谁知道为什么它在我的应用程序上下文中不起作用?

标签: javaspring-boot

解决方案


推荐阅读