简体   繁体   English

如何在Java中加载类路径资源,同时跳过本地Maven存储库中的内容

[英]How to load classpath resources in java while skipping content from local maven repo

I'm getting resources from the classpath as following. 我从类路径获取资源,如下所示。

Resource[] compiledResources = loader.getResources("classpath:jasper/compiled/*.*");

However when I load resources like this I'm getting content form the same jar which is already in the local maven M2 repository; 但是,当我像这样加载资源时,我从本地maven M2存储库中已有的jar获取内容。 since it's already in the classpath. 因为它已经在类路径中了。

Is there a way to avoid this ? 有办法避免这种情况吗?

If I understand your question correctly, you need to include a custom jar in classpath rather than utilizing the m2 repo based jar. 如果我正确理解了您的问题,则需要在类路径中包含一个自定义jar,而不要利用基于m2 repo的jar。 you can add the dependency with scope "provided" and add localPath option with appropriate location of jar for the same. 您可以使用范围“提供”添加依赖项,并使用jar的适当位置添加localPath选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM