依赖项中的资源未添加到类路径中

时间:2015-04-14 08:47:30

标签: java intellij-idea gradle resources dependencies

我是IntelliJ的新手,我想按如下方式设置项目:
我想要处理的产品作为gradle构建文件中的编译依赖项包含在内。它有很多传递依赖。

该产品包括一个Jetty Application Server,我想用运行配置启动它 如果我尝试运行它,我遇到一个问题,Application Server将无法启动,因为它找不到依赖项中包含的资源文件。这些文件特定于此产品,并具有自定义文件格式。如果我在“Project Explorer”中查看这些依赖项,我可以找到这些文件,但似乎它们没有正确添加到类路径中。

您知道解决此问题的方法吗?

编辑:添加了控制台输出

"C:\Program Files\Java\jdk1.7.0_75\bin\java" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:53443,suspend=y,server=n -javaagent:C:\Users\xyzhe\.IntelliJIdea14\system\groovyHotSwap\gragent.jar -classpath "C:\Program Files (x86)\JetBrains\IntelliJ IDEA 14.1.1\lib\idea_rt.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 14.1.1\lib\util.jar" -Dfile.encoding=windows-1252 com.intellij.rt.execution.CommandLineWrapper C:\Users\xyzhe\AppData\Local\Temp\classpath1.tmp com.xyz.xyz.server.ApplicationServer

[...]

DEBUG    2| Java classpath (java.class.path): 
    C:\Workspaces\idea\test\build\resources\main
    C:\Program Files\Java\jdk1.7.0_75\jre\lib\charsets.jar
    C:\Program Files\Java\jdk1.7.0_75\jre\lib\deploy.jar
    C:\Program Files\Java\jdk1.7.0_75\jre\lib\javaws.jar
    C:\Program Files\Java\jdk1.7.0_75\jre\lib\jce.jar
    C:\Program Files\Java\jdk1.7.0_75\jre\lib\jfr.jar
    C:\Program Files\Java\jdk1.7.0_75\jre\lib\jfxrt.jar
    C:\Program Files\Java\jdk1.7.0_75\jre\lib\jsse.jar
    C:\Program Files\Java\jdk1.7.0_75\jre\lib\management-agent.jar
    C:\Program Files\Java\jdk1.7.0_75\jre\lib\plugin.jar
    C:\Program Files\Java\jdk1.7.0_75\jre\lib\resources.jar
    C:\Program Files\Java\jdk1.7.0_75\jre\lib\rt.jar
    C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\access-bridge-64.jar
    C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\dnsns.jar
    C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\jaccess.jar
    C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\localedata.jar
    C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\sunec.jar
    C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\sunjce_provider.jar
    C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\sunmscapi.jar
    C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\zipfs.jar
    D:\gradle-repository\caches\modules-2\files-2.1\com.xyz.customersolution.gradle.templates\database-jar-fix\1.0.2-SNAPSHOT\130dddff1f42c974ae3596d930650f0625bb6ce0\database-jar-fix-1.0.2-SNAPSHOT.jar
    D:\gradle-repository\caches\modules-2\files-2.1\org.eclipse.jetty.orbit\org.eclipse.jdt.core\3.8.2.v20130121\ebb04771ae21dec8682e4153e97404d9933a9c13\org.eclipse.jdt.core-3.8.2.v20130121.jar
    D:\gradle-repository\caches\modules-2\files-2.1\com.xyz.xyz\standardreports\5.4.0\a7cb55b52375485e9e7a50f1178f8422c051c060\standardreports-5.4.0.jar
    D:\gradle-repository\caches\modules-2\files-2.1\com.xyz.xyz\xyz\5.4.0\ca28dfa960714909e2a8f90bcc76f6a0b6b49ca8\xyz-5.4.0.jar
    D:\gradle-repository\caches\modules-2\files-2.1\org.apache.wicket\wicket-core\6.11.0\8053fa17c6763d3cab3c9f29b15b2249fd3965b6\wicket-core-6.11.0.jar
    D:\gradle-repository\caches\modules-2\files-2.1\com.xyz.xyz\xml-form-generator\5.4.0\1fdac3321d5cd3d924ff5b1072d7e238a89f86d5\xml-form-generator-5.4.0.jar
    D:\gradle-repository\caches\modules-2\files-2.1\com.xyz.xyz\as\5.4.0\91c7fd68d3d54ab6543c08bb00328bb6c2ee0b4d\as-5.4.0.jar
    D:\gradle-repository\caches\modules-2\files-2.1\com.xyz.xyz\mangocards\5.4.0\9cf3d615525d181c3f9664ebf7aaf621ad50b744\mangocards-5.4.0.jar
    D:\gradle-repository\caches\modules-2\files-2.1\com.xyz.xyz\persistence\5.4.0\3ab80e15a1cf5b07be5ec103229289caf1658e51\persistence-5.4.0.jar
    D:\gradle-repository\caches\modules-2\files-2.1\com.xyz.xyz\processpages\5.4.0\1969ebd46e33a60efcb7d0eadc2716d5a576ba56\processpages-5.4.0.jar
    D:\gradle-repository\caches\modules-2\files-2.1\com.xyz.xyz\scheduling\5.4.0\59a3adcc87eefc15f2b09908aa084bbabc87618c\scheduling-5.4.0.jar
    D:\gradle-repository\caches\modules-2\files-2.1\com.xyz.xyz\xyz-permissions\5.4.0\c2dfc971d1ca566115a1c2909cf2dc375d768856\xyz-permissions-5.4.0.jar
    D:\gradle-repository\caches\modules-2\files-2.1\com.xyz.xyz\import\5.4.0\e897764ebe7c789cf5e96b776b27c303b2660716\import-5.4.0.jar
    D:\gradle-repository\caches\modules-2\files-2.1\com.xyz.xyz\cti\5.4.0\632320b61aaaf11dc5c01a844e4497ec4a2a788b\cti-5.4.0.jar
    D:\gradle-repository\caches\modules-2\files-2.1\com.xyz.xyz\mobile\5.4.0\e1d004b497714dab8ccd05ac4b47652fe5073c09\mobile-5.4.0.jar
    D:\gradle-repository\caches\modules-2\files-2.1\com.xyz.utils.logging\logging-logback\1.4\2686750910ad01a75c9a0944fb3a84cd86f5d9d\logging-logback-1.4.jar
    D:\gradle-repository\caches\modules-2\files-2.1\com.xyz.utils.webauth\web-authentication\0.9\ea71e4ce1d4f7a37515af2b07d515adb33384173\web-authentication-0.9.jar
    D:\gradle-repository\caches\modules-2\files-2.1\com.xyz.xyz\mangodata\5.4.0\1b657225530e22f3c28603b3710360b37de23b94\mangodata-5.4.0.jar
    D:\gradle-repository\caches\modules-2\files-2.1\com.xyz.xyz\wm-implementation\5.4.0\c38dbe4fcfecc4074b3a80f965d6415201fc3db4\wm-implementation-5.4.0.jar
    D:\gradle-repository\caches\modules-2\files-2.1\com.xyz.xyz\planboard-gui\5.4.0\4e47e003fa9b7da7c14d009345bfcd9c4cae8dac\planboard-gui-5.4.0.jar
    D:\gradle-repository\caches\modules-2\files-2.1\com.xyz.xyz\importwizard\5.4.0\86452ecf87035ab51a2fb06ec3f14bcffce9e9d2\importwizard-5.4.0.jar
    D:\gradle-repository\caches\modules-2\files-2.1\antlr\antlr\2.7.7\83cd2cd674a217ade95a4bb83a8a14f351f48bd0\antlr-2.7.7.jar
    D:\gradle-repository\caches\modules-2\files-2.1\com.novel.ecb\ecb\1.4\b71404cc296e6d4f4670ee78366a0b95181cb0ee\ecb-1.4.jar
    D:\gradle-repository\caches\modules-2\files-2.1\com.novel.ecb\ecbldap\1.4\6897a1d220d5f7e74b49246f9931707ce802a79b\ecbldap-1.4.jar
[...]
INFO     2| Loading BZR lists "bzrlist_admin.bzrs"...                                                                                               | com.xyz.bzr.support.ParsedDefinitionSetHelper.createFromIntermediateResources(ParsedDefinitionSetHelper.java:88)
WARN     2| No BZR lists named "bzrlist_admin.bzrs"                                                                                                 | com.xyz.bzr.support.ParsedDefinitionSetHelper.createFromIntermediateResources(ParsedDefinitionSetHelper.java:113)
INFO     2| Resolving...                                                                                                                            | com.xyz.bzr.resolver.DefinitionResolver.resolveInternally(DefinitionResolver.java:172)
INFO     2| Loading BZR lists "corebzrlist.bzrs"...                                                                                                 | com.xyz.bzr.support.ParsedDefinitionSetHelper.createFromIntermediateResources(ParsedDefinitionSetHelper.java:88)
WARN     2| No BZR lists named "corebzrlist.bzrs"                                                                                                   | com.xyz.bzr.support.ParsedDefinitionSetHelper.createFromIntermediateResources(ParsedDefinitionSetHelper.java:113)
INFO     2| Loading BZR lists "bzrlist.bzrs"...                                                                                                     | com.xyz.bzr.support.ParsedDefinitionSetHelper.createFromIntermediateResources(ParsedDefinitionSetHelper.java:88)
WARN     2| No BZR lists named "bzrlist.bzrs"                                                                                                       | com.xyz.bzr.support.ParsedDefinitionSetHelper.createFromIntermediateResources(ParsedDefinitionSetHelper.java:113)
INFO     2| Resolving...                                                                                                                            | com.xyz.bzr.resolver.DefinitionResolver.resolveInternally(DefinitionResolver.java:172)
INFO     2| No file 'management.users' present    

编辑:更正Eclipse输出

INFO     2| Loading BZR lists "corebzrlist.bzrs"      com.xyz.bzr.support.ParsedDefinitionSetHelper.createFromIntermediateResources(ParsedDefinitionSetHelper.java:78)
INFO     2| - Loading BZRs from "file:/D:/gradle-repository/caches/modules-2/files-2.1/com.xyz.tas/xyz-core-bzr/5.6.0-beta5-20150326-1730/bf9bd5caf5977f7506c66f43f586b2eead4c3a55/xyz-core-bzr-5.6.0-beta5-20150326-1730.jar!/corebzrlist.bzrs"...     | com.xyz.bzr.support.ParsedDefinitionSetHelper.createFromIntermediateResources(ParsedDefinitionSetHelper.java:85)

编辑:添加了项目资源管理器的图像

Project Explorer

1 个答案:

答案 0 :(得分:0)

因此,在这种情况下的解决方案是使用了错误的类加载器。

ClassLoader.getSystemClassLoader()返回的类加载器实例无法获取所需的资源。显然这个类加载器正在使用错误的类路径。

在大多数情况下,最好使用Thread.currentThread().getContextClassLoader()

返回的当前执行上下文的类加载器