简体   繁体   English

Glassfish 3.1.2不包含javax.persistence jar

[英]Glassfish 3.1.2 doesn't contain javax.persistence jar

I'm trying to work with Eclipse Mars 2 and Glassfish 3.1.2, but when I use EclipseLink 2.1 to create the entitites from tables, javax.persistence is not found in the buildpath. 我正在尝试使用Eclipse Mars 2和Glassfish 3.1.2,但是当我使用EclipseLink 2.1从表创建实体时,在构建路径中找不到javax.persistence。

Is this the normal behaviour? 这是正常行为吗?

  1. I created the Oracle db connection with eclipse 我用eclipse创建了Oracle数据库连接
  2. I installed JEE 6 SDK with Glassfish 3 我在Glassfish 3上安装了JEE 6 SDK
  3. I started the glassfish server and configured the data source and connection pool. 我启动了glassfish服务器,并配置了数据源和连接池。
  4. I created a JPA project and created the entities from the db connection tables. 我创建了一个JPA项目,并从数据库连接表中创建了实体。

Something I find curious is that the jee.jar that is inside glassfish/lib only contains a pom.xml 我发现奇怪的是,glassfish / lib内的jee.jar仅包含pom.xml

Isn't Glassfish supposed to contain all the jars needed to develop with the jee standard? Glassfish是否不应该包含用jee标准开发的所有罐子?

Is my project meant to be a Maven project in order to automatically download this jars? 我的项目是要自动下载此jar的Maven项目吗? Could I fix this by configuring my project as a Maven project? 我可以通过将项目配置为Maven项目来解决此问题吗?

Isn't Glassfish supposed to contain all the jars needed to develop with the jee standard? Glassfish是否不应该包含用jee标准开发的所有罐子?

Yes, and it contains all the jars needed but in an indirect way. 是的,它以间接方式包含了所有需要的罐子。 Even though it is a single jar file with only one file, namely, MANIFEST.MF and a directory maven which contains the pom file you mentioned. 即使它是一个只有一个文件的jar文件,也就是MANIFEST.MF和包含您提到的pom文件的目录maven

But if you open the MANIFEST.MF file you'll see that it is pointing to a lot of jar files in the Class-Path: entry which you need to be able develop JavaEE applications. 但是,如果打开MANIFEST.MF文件,您将看到它指向Class-Path:条目中的许多jar文件,您需要这些文件才能开发JavaEE应用程序。

So everything is there and you only need to add this file into your dependency to be able to compile your JavaEE (Servlets, JSF, EJB, JPA, ...) classes and deploy on the server. 因此,一切都已存在,您只需要将此文件添加到依赖项中就可以编译JavaEE(Servlet,JSF,EJB,JPA等)类并在服务器上进行部署。 But this (javaee.jar) must be a compile time dependency, ie, should not be packaged with your application as the jars are already contained in the server. 但是,此(javaee.jar)必须是编译时依赖项,即,不应将其与应用程序打包在一起,因为jar已包含在服务器中。

Is my project meant to be a Maven project in order to automatically download this jars? 我的项目是要自动下载此jar的Maven项目吗?

No. Your project can be but should not be a maven project. 不可以。您的项目可以是但不应该是Maven项目。 Let us say, for example, you have an Eclipse project where you want to develop an EJB application. 举例来说,假设您有一个Eclipse项目,您想在其中开发EJB应用程序。 Just right click on the project 只需右键单击该项目

  • go to the Properties -> Build Path page and change to Libraries tab 转到“ Properties -> Build Path页面,然后更改为“ Libraries选项卡

  • click on Add External Jars ... 单击Add External Jars ...

  • go to the Glassfish lib directory and add the javaee.jar , and you are done. 转到Glassfish lib目录并添加javaee.jar ,您就完成了。
  • now you can use all the JavaEE annotations and classes. 现在您可以使用所有JavaEE注释和类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM