JAR文件ADD DIRECTORY ENTRIES导出jar时的Eclipse选项 [英] Jar file ADD DIRECTORY ENTRIES Eclipse option while exporting jar
问题描述
实际上,我遇到了从jar文件引用类文件的场景。
我的意思是说我有一个后端java项目说ABC中有application-context.xml文件。
现在我创建了ABC项目的jar文件,在一个基于Web的应用程序中使用。
这里我面临一个问题,豆没有获得Autowired并且知道问题是
当我导出jar使用Eclipse的ABC项目文件,我没有选择
ADD DIRECTORY ENTRIES复选框,稍后我做了所有工作。
只是为了看看有什么变化已经通过在jar文件中检查这个框,使所有的工作,
所以我创建了2个jar文件,其中一个ADD DIRECTORY ENTRIES被检查,一个没有选中,然后我比较了两个罐子比较,发现没有任何区别。
有人可以解释一下ADD DIRECTORY ENTRIES是什么?
我知道是应该添加完整的结构而不是像
com / company / project / MyJavaFile.class
com / company /
com / company / project /
com / company / project / MyJavaFile.class
如果我错了,请更正我。
如果需要使用class.getResource()方法获取,您应该在创建jar文件时启用添加目录条目 jar文件中特定目录的URI。您可能想要这样做的原因是为您的资源文件夹保留一个URI。
如果您只使用class.getResource()获取特定文件的URI [而不是目录],那么如果离开添加目录条目,您将会很好。
I don't whether I am asking correct question or not but want to clear my doubt.
Actually I came across the scenario of referring class files from jar file. I mean to say I have one backend java project say ABC with application-context.xml file in it.
Now I created jar file of ABC project and used in one web based application.
Here I am facing a problem of beans not getting Autowired and came to know the problem was, When I export the jar file of ABC project using Eclipse, I have not selected "ADD DIRECTORY ENTRIES" checkbox which later on I did and all worked.
just to see what changes has been made by checking this box in a jar file so that all worked,
So I created 2 jar files one with "ADD DIRECTORY ENTRIES" checked and one with unchecked, then I compared both jar using beyond compare and found there is no difference at all.
Can someone explain me what exactly "ADD DIRECTORY ENTRIES" does?
what I know is it should add complete structure instead of single path like com/company/project/MyJavaFile.class
com/company/
com/company/project/
com/company/project/MyJavaFile.class
Please correct me if I am wrong.
You should enable "Add directory entries" when creating jar files if you need to use class.getResource() method to get the URI of a particular directory inside your jar file. The reason why you may want to do this is to hold a URI to your "resource" folder for example.
If you only use class.getResource() to get the URI of a specific file [and not a directory] then you will be fine if you leave the "Add directory entries" off.
这篇关于JAR文件ADD DIRECTORY ENTRIES导出jar时的Eclipse选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!