eclipse javax.persistence.* 来源,在哪里?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4804025/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 15:41:58  来源:igfitidea点击:

javax.persistence.* sources, where?

javaeclipsejpaeclipselink

提问by pnt

I might be missing something really obvious here, but I couldn't find the sources for a few classes from the javax.persistence package.

我可能在这里遗漏了一些非常明显的东西,但我无法从 javax.persistence 包中找到一些类的来源。

I'm using EclipseLink as a JPA provider. When I tried Ctrl+left clicking a method of the EntityManager interface, Eclipse said that I should attach the sources since it can't find them. I tried attaching the EclipseLink ones but it complained it cannot find the source for EntityManager there.

我使用 EclipseLink 作为 JPA 提供程序。当我尝试 Ctrl+左键单击 EntityManager 接口的方法时,Eclipse 说我应该附加源,因为它找不到它们。我尝试附加 EclipseLink 的,但它抱怨在那里找不到 EntityManager 的源。

What sources do I need to attach in order to view the code in Eclipse? Could somebody provide a link?

我需要附加哪些源才能在 Eclipse 中查看代码?有人可以提供链接吗?

采纳答案by James

I think if you create a JPA project type in Eclipse you will be able to see the JPA source, or perhaps load the JPA module.

我认为如果您在 Eclipse 中创建 JPA 项目类型,您将能够看到 JPA 源,或者可能加载 JPA 模块。

Only the source code to EclipseLink is in the eclipselink-src.jar, you can access the source to JPA from the EclipseLink repository,

只有 EclipseLink 的源代码在 eclipselink-src.jar 中,您可以从 EclipseLink 存储库访问 JPA 的源代码,

http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/jpa/plugins/

http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/jpa/plugins/

The source is not that interesting for JPA, as it is a spec, and all interfaces, there is little to no real code.

源代码对于 JPA 来说不是那么有趣,因为它是一个规范,并且所有接口都几乎没有真正的代码。

回答by Andrei Sura

The actual implementations of the interfaces can be seen by cloning the git repo:

通过克隆 git repo 可以看到接口的实际实现:

git clone https://github.com/eclipse/javax.persistence.git
cd javax.persistence

== Then find a specific function

== 然后找具体的函数

grep -ir 'close()' *
src/javax/persistence/EntityManager.java:    public void close();
src/javax/persistence/EntityManagerFactory.java:    public void close();
src/javax/persistence/spi/PersistenceProviderResolverHolder.java: in.close();

回答by dira

IF you use maven

如果你使用 maven

  1. Issue mvn eclipse:eclipse -DdownloadSource=truecommand, to download the sources jars to local .m2repo.
  2. refresh the project in eclipse.
  1. 发出mvn eclipse:eclipse -DdownloadSource=true命令,将源 jar 下载到本地存储.m2库。
  2. 在 Eclipse 中刷新项目。

If you use m2eclipseplugin,

如果你使用m2eclipse插件,

  1. right click on project --> Maven --> Download Sources.
  2. right click on project --> Maven --> Update Project Configuration.
  1. 右键单击项目 --> Maven --> 下载源。
  2. 右键单击项目 --> Maven --> 更新项目配置。

回答by nanda

Maybe you used different version for the classes jar and the sources jar?

也许您对类 jar 和源 jar 使用了不同的版本?

回答by DataNucleus

You can get the equivalent from Apache http://repo2.maven.org/maven2/org/apache/geronimo/specs/geronimo-jpa_2.0_spec/1.1/and that directory has source and runtime jar. And that's under a more flexible Apache 2 license

您可以从 Apache http://repo2.maven.org/maven2/org/apache/geronimo/specs/geronimo-jpa_2.0_spec/1.1/获得等效文件, 并且该目录具有源代码和运行时 jar。这是在更灵活的 Apache 2 许可下