java.lang.ClassNotFoundException: javax.persistence.Entity
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12932851/
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
java.lang.ClassNotFoundException: javax.persistence.Entity
提问by coure2011
I got a sample project, copied from somewhere else, when I am trying to run it in netbeans I am getting some error/exceptions in tomcat's console window.
我有一个示例项目,从其他地方复制,当我尝试在 netbeans 中运行它时,我在 tomcat 的控制台窗口中收到一些错误/异常。
java.lang.ClassNotFoundException: javax.persistence.Entity
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
at org.springframework.core.type.classreading.RecursiveAnnotationAttributesVisitor.visitEnd(AnnotationAttributesReadingVisitor.java:167)
at org.springframework.asm.ClassReader.a(Unknown Source)
at org.springframework.asm.ClassReader.accept(Unknown Source)
at org.springframework.asm.ClassReader.accept(Unknown Source)
javax.persistence is already added to my project. I even removed and re-added in netbeans but still same error. This error is when running the web applictation not when compiling.
javax.persistence 已经添加到我的项目中。我什至在 netbeans 中删除并重新添加,但仍然是同样的错误。这个错误是在运行 web 应用程序时而不是在编译时。
采纳答案by Rohit Jain
You need to add following Jar Files
to your Build Path: -
您需要Jar Files
在构建路径中添加以下内容:-
javax.persistence_2.0.3.v201010191057.jar
org.eclipse.persistence.jpa_2.3.0.v20110604-r9504.jar
org.eclipse.persistence.jpa.equinox_2.3.1.v20111018-r10243.jar
org.eclipse.persistence.antlr_2.3.0.v20110604-r9504.jar
org.eclipse.persistence.asm_2.3.0.v20110604-r9504.jar
javax.persistence_2.0.3.v201010191057.jar
org.eclipse.persistence.jpa_2.3.0.v20110604-r9504.jar
org.eclipse.persistence.jpa.equinox_2.3.1.v20111018-r10243.jar
org.eclipse.persistence.antlr_2.3.0.v20110604-r9504.jar
org.eclipse.persistence.asm_2.3.0.v20110604-r9504.jar
Preferably adding the first one will work, as javax.persistence.Entity
is found in that Jar
only.
But you may also need to add the later ones, for working with JPA
最好添加第一个会起作用,正如仅javax.persistence.Entity
在其中发现的那样Jar
。但是您可能还需要添加后面的,以便与JPA
Google them with the name of JPA Jars. You will get them.
用 JPA 罐子的名字谷歌它们。你会得到它们。
回答by Sathish
The javax.persistence.Entity is a class inside the Java EE SDK library “javaee.jar“, you are missing this jar file in your project classpath.
javax.persistence.Entity 是 Java EE SDK 库“javaee.jar”中的一个类,您的项目类路径中缺少此 jar 文件。
refer this http://www.mkyong.com/hibernate/java-lang-classnotfoundexception-javax-persistence-entity/
参考这个http://www.mkyong.com/hibernate/java-lang-classnotfoundexception-javax-persistence-entity/