Eclipse:无法生成串行版本 ID
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17652439/
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
Eclipse : Cannot generate a serial version ID
提问by Tity
I have an issue with Eclipse 3.6 (Helios) :
我有 Eclipse 3.6 (Helios) 的问题:
Anytime I want to generate a serial version ID (serialVersionUID
) for a class that extends a serializable
class, I get the following message :
每当我想为serialVersionUID
扩展serializable
类的类生成串行版本 ID ( ) 时,我都会收到以下消息:
The following error occured : Could not find class file. Make sure the file is compilable.
发生以下错误:找不到类文件。确保文件是可编译的。
What am I doing wrong ?
我究竟做错了什么 ?
Thank you.
谢谢你。
回答by Po Zhou
In my case, I've solved this problem by the following way:
就我而言,我通过以下方式解决了这个问题:
Right click the project, "Build Path" -> "Configure Build Path" -> "Source" tab, remove paths tagged "missing".
右键单击项目,“构建路径”->“配置构建路径”->“源”选项卡,删除标记为“缺失”的路径。
回答by Marc Le Bihan
Sometimes a tool (AspectJ - AJDT for instance or another) removes the Java Nature of the project, and it doesn't compile while it doesn't show any error on the editor.
有时一个工具(例如 AspectJ - AJDT 或其他)会删除项目的 Java 性质,并且它不会编译,同时它不会在编辑器上显示任何错误。
Check that you have a .project file that contains both entries : org.eclipse.jdt.core.javabuilderand org.eclipse.jdt.core.javanature
检查您是否有一个包含两个条目的 .project 文件: org.eclipse.jdt.core.javabuilder和org.eclipse.jdt.core.javanature
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Myproject</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<!-- This one is required -->
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<!-- This one is required too -->
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
</projectDescription>
回答by madhu_karnati
If you have any build problems( errors ), eclipse will give
如果您有任何构建问题(错误),eclipse 会给
Could not find class file. Make sure the file is compilable.
error. Make sure their are no problems with your build path(like... Missisng class folders/jars ).
错误。确保他们的构建路径没有问题(例如... Missisng class folders/jars )。
回答by Grim
Eclipse use the org.eclipse.jdt.core.javabuilder
-Builder to locate the .class
-Files. But either the Builder did not start or did not found the .class
-files.
Eclipse 使用org.eclipse.jdt.core.javabuilder
-Builder 来定位 -Files .class
。但是 Builder 没有启动或没有找到.class
-files。
Reduce the .project
-File to
将.project
-File减少到
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>yourprojectsname</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Remove all of maven's build-path entries.
删除所有 maven 的构建路径条目。
Add the Maven nature.
添加Maven性质。
Thats all.
就这样。
回答by Boles?aw Denk
There is a bug issiue: https://bugs.eclipse.org/bugs/show_bug.cgi?id=259506
有一个错误问题:https://bugs.eclipse.org/bugs/show_bug.cgi ?id =259506
Aside of modifing .project file as Marc has stated, Andrew Eisenberg suggested to try closing and openiong project again.
除了 Marc 所说的修改 .project 文件之外,Andrew Eisenberg 建议再次尝试关闭和打开项目。
Using both helped in my case.
在我的情况下使用两者都有帮助。
EDIT:Some time ago I moved to eclipse with integrated AspectJ Development Tools. Since then I have avaiable options for aspectJ which work every time.
编辑:前段时间我使用集成的 AspectJ 开发工具转向 eclipse。从那时起,我就有了每次都可以使用的 aspectJ 选项。
回答by Love Sharma
In my case also I used ,
在我的情况下,我也使用了,
Right click the project, "Build Path" -> "Configure Build Path" -> "Source" tab, remove paths tagged "missing". Though I am not sure will it impact the project dependencies on any thing.
右键单击项目,“构建路径”->“配置构建路径”->“源”选项卡,删除标记为“缺失”的路径。虽然我不确定它是否会影响项目对任何事情的依赖。
回答by lewdev
Go to:
去:
Window > Show View > Other..
Window > Show View > Other..
Select:
选择:
General > Problems
General > Problems
You can see all the Eclipse problems which include jar dependencies. My issue was that I was missing a required jar file. Once I added that jar file, the issue got fixed.
您可以看到所有包含 jar 依赖项的 Eclipse 问题。我的问题是我缺少必需的 jar 文件。一旦我添加了那个 jar 文件,问题就解决了。
回答by Yassine Cherif
In my case, I had multiple projects in my eclipse workspace. The solution is to first fix all your current project's errors, then go to "Problems" view and either fix or delete all Errors there.
就我而言,我的 eclipse 工作区中有多个项目。解决方案是首先修复当前项目的所有错误,然后转到“问题”视图并修复或删除那里的所有错误。
Now if you re-execute the eclipse quickfix "Add generated serial version ID" it should work fine.
现在,如果您重新执行 eclipse 快速修复程序“添加生成的串行版本 ID”,它应该可以正常工作。
回答by Damo
In my case (I'm using Maven), I had to delete one of the dependencies in the local repository because it had become corrupted. Look for errors about problem reading dependency jars.
就我而言(我使用的是 Maven),我不得不删除本地存储库中的依赖项之一,因为它已损坏。查找有关读取依赖项 jar 的问题的错误。
回答by Efrain Toribio Reyes
I had the same problem. This has worked for me:
我有同样的问题。这对我有用:
- Go to tab Navigator: Window > Show View > Navigator
- Right Click on Project
- Build Project
- 转到选项卡导航器:窗口 > 显示视图 > 导航器
- 右键单击项目
- 构建项目
Try generate serial version ID again
再次尝试生成序列版本 ID