Java 创建新工件时出现错误“MANIFEST.MF 已存在于 VFS”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31189449/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error "MANIFEST.MF already exists in VFS" when creating new artifact
提问by mjtik
I have a Java project that I used to be able to build artifacts from, but now I am unable to.
我有一个 Java 项目,我曾经能够从中构建工件,但现在我不能了。
First, my project was building and I was able to create artifacts, but on running the .jar
I was getting "Java Exemption Error"
. I checked to see what version of the compiler I was using (1.8)
and made sure my machine was up to date.
首先,我的项目正在构建并且我能够创建工件,但是在运行时.jar
我得到了"Java Exemption Error"
. 我检查了我正在使用的编译器版本,(1.8)
并确保我的机器是最新的。
Next I tried to fix any dependency issues by deleting and re-associating some of my external .jar
files.
接下来,我尝试通过删除并重新关联我的一些外部.jar
文件来解决任何依赖性问题。
Then I deleted the artifact setting and tried to create a new one. Now I receive a
然后我删除了工件设置并尝试创建一个新设置。现在我收到一个
.../MANIFEST.MF already exists in VFS
.../MANIFEST.MF 已经存在于 VFS 中
error when trying to create a new artifact.
尝试创建新工件时出错。
I'm using the latest version of Intellij. My source code can be found here: https://github.com/mjtik/PiccoApp.
我正在使用最新版本的 Intellij。我的源代码可以在这里找到:https: //github.com/mjtik/PiccoApp。
I can provide screen shots if necessary.
如有必要,我可以提供屏幕截图。
*I have created many .jars in the past, not sure what changed in my project.
*我过去创建了许多 .jars,不确定我的项目发生了什么变化。
Any suggestions or guidance would be appreciated.
任何建议或指导将不胜感激。
回答by mjtik
I solved my problem. Ever step I took lead me to the solution. The problem was with how I was creating the new artifact.
我解决了我的问题。我采取的每一步都引导我找到解决方案。问题在于我如何创建新工件。
When creating the new artifact, I selected JAR and then a popup window displays default settings. It has me app module selected and the main class below is blank.
创建新工件时,我选择了 JAR,然后一个弹出窗口显示了默认设置。它选择了我的应用程序模块,下面的主类是空白的。
I was selecting the main class and it was producing an error. When I just accepted the default options left the main class blank, the artifact was created.
我正在选择主类,但它产生了错误。当我刚刚接受默认选项时,主类留空,工件就创建了。
回答by The-Droidster
Another solution would be to just :
另一种解决方案是:
- Navigate to $HOME$\IdeaProjects\ProjectFolder\src\META-INF and delete the MANIFEST.MF file in there.
- Restart IntelliJ Idea
- Go to Project Structure > Artifacts -> delete your project artifact setting
- Add new artifact setting and reconfigure as required.
- 导航到 $HOME$\IdeaProjects\ProjectFolder\src\META-INF 并删除其中的 MANIFEST.MF 文件。
- 重启 IntelliJ Idea
- 转到项目结构 > 工件 -> 删除您的项目工件设置
- 添加新的工件设置并根据需要重新配置。
回答by Karthic Raghupathi
I inherited a project which already had the MANIFEST.MF
file in the META-INF
folder in the src
folder. But this project did not have a artifact configured in the project structure dialog box. I also don't think that deleting an existing file and restarting Idea is an ideal solution for this problem.
我继承了一个项目,该项目已在MANIFEST.MF
文件META-INF
夹中的src
文件夹中包含该文件。但是这个项目没有在项目结构对话框中配置神器。我也不认为删除现有文件并重新启动 Idea 是解决此问题的理想方法。
I've listed below the steps that worked for me and these were done on Intellij Idea 2016.1.
我在下面列出了对我有用的步骤,这些步骤是在 Intellij Idea 2016.1 上完成的。
Step 1:Choose Emptywhen you want to add an artifact to create a JAR
file with an existing MANIFEST.MF
file. Do NOTselect From module with dependenciesas that will lead to the error described in the question.
步骤 1:当您要添加工件以使用现有文件创建文件时,请选择Empty。千万不要选择从模块的依赖性因为这将导致该问题描述的错误。JAR
MANIFEST.MF
Step 2:In the next screen, select the Use Existing Manifestbutton to navigate to and select the existing MANIFEST.MF
file. Make any other changes you need now so the JAR
artifact is created per your needs.
第 2 步:在下一个屏幕中,选择“使用现有清单”按钮导航到并选择现有MANIFEST.MF
文件。现在进行您需要的任何其他更改,以便JAR
根据您的需要创建工件。
Step 3:Select OK and you should be all set now. Depending on whether you selected build on make and make your project or if you specifically generate the artifact, your JAR
would get created without any issues.
第 3 步:选择 OK,您现在应该已经全部设置好了。根据您是选择在 make 上构建并制作您的项目,还是您专门生成工件,您的JAR
创建将没有任何问题。
回答by Christine
I use "create artifact from modules". If I get the notification for the manifest that exists, I delete the manifest file, then do "invalidate caches and restart". I think Intellij is complaining about a copy of that file that's in the cache.
我使用“从模块创建工件”。如果我收到存在清单的通知,我会删除清单文件,然后执行“使缓存无效并重新启动”。我认为 Intellij 是在抱怨缓存中该文件的副本。