Java Spring的AntPathMatcher与linux路径匹配行为

Java Spring的AntPathMatcher与linux路径匹配行为,java,regex,spring,ant,Java,Regex,Spring,Ant,我在下面的单元测试中发现了这种奇怪的行为: @Test public void testAntPathMacherPotentiallyBrokenForNix() throws IOException { AntPathMatcher antPathMatcher = new AntPathMatcher(); Resource resource = new ClassPathResource("properties/RESOURCE_TEST.prop

我在下面的单元测试中发现了这种奇怪的行为:

@Test
    public void testAntPathMacherPotentiallyBrokenForNix() throws IOException {
        AntPathMatcher antPathMatcher = new AntPathMatcher();
        Resource resource = new ClassPathResource("properties/RESOURCE_TEST.properties"); // there's a RESOURCE_TEST.properties under a directory 'properties'
        String localPath = resource.getFile().getAbsolutePath();

        Assert.assertThat(antPathMatcher.match("*.properties", localPath), is(true));

        String nixPath = "/local/app/instances/properties/RESOURCE_TEST.properties";

        Assert.assertThat(antPathMatcher.match("*.properties", nixPath), is(true));
}
第二个断言失败了,但是上面的两个断言不都应该是真的吗


我错过了什么?并不是说我真的必须使用AntPathMatcher,我只是好奇

我试图复制它,但在Spring 3中,两个版本都失败了,我再也没有接触过2.5了:-

原因:不能用通配符启动路径,需要根来定位

使用以下模式:/***/.properties,至少在Spring 3中,两个测试都会成功。

尝试以下方法:

antPathMatcher.setPathSeparatorSystem.getPropertyfile.separator