Finding Resources with PathMatchingResourcePatternResolver and URLClassloader in JARs

前端 未结 2 524
眼角桃花
眼角桃花 2020-12-08 07:05

I am trying to load all resources with a specific file-extension which are loaded dynamically at runtime using a URLClassloader.

Unfortunately the PathMatchingResour

2条回答
  •  轮回少年
    2020-12-08 07:33

    As Tech Trip mentioned in the comment to his answer, I had an error in my pattern. The Spring-documentation is also quiet clear about that (see Warning): "classpath*:" when combined with Ant-style patterns will only work reliably with at least one root directory before the pattern starts...originates from a limitation in the JDK's ClassLoader.getResources()

    So I changed my pattern to

    classpath*/model/*.myextension
    

    Since the JARs are created from an xText-DSL I have to enforce a convention that the model-folder has to be used.

提交回复
热议问题