设置Eclipse以使用Java EE [英] Set up Eclipse to work with Java EE

查看:166
本文介绍了设置Eclipse以使用Java EE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先要注意的是,我对EE很熟悉,特别是Eclipse(我在我的生活中第二次与Eclipse合作过):)



然后我打开了由其他人创建的Eclipse项目。它正在使用Java EE(一些EJB,Persistence API ...)。无法运行此项目,有编译错误 - 我无法使用EE库 - 它看起来像这样:





不知道它是已知的,没有快速修复。此外,该项目还包含Maven依赖项(我已经设法为Eclipse安装Maven插件),依赖关系的所有类都在代码中显示警告。像这样:





如何设置Eclipse来处理这个EE项目以便能够编译并运行它?
感谢您的答案。



编辑:我使用的是Eclipse 2.0.0.2,我必须使用它 - 它的Rational Team Concept版本的Eclipse和2.0.0.2以上的版本与RTC服务器不兼容。

解决方案

必须在项目的构建路径中包含Java EE API。 Java EE API本质上是应用程序服务器,例如您似乎已经拥有的Oracle Glassfish。



在Eclipse中,打开右下角的服务器视图。如果没有,那么你需要添加它。右键单击并选择新建。巫师应该自己说话。如果Sun或Oracle Glassfish没有选项,那么您必须单独安装Eclipse插件。在较新的Eclipse版本中,您可以通过单击向导顶部的下载其他服务器适配器,然后选择Oracle Glassfish服务器工具来实现。如果在较旧的Eclipse版本中,则需要按照其主页中的说明手动安装。



将服务器集成到Eclipse(或实际上已经有)集成在一起之后,您应该右键单击动态Web项目并转到目标运行时 。在那里选择集成的服务器。必要时重建。


First note that I'm new to EE and particulary to Eclipse (I'm seriosly working with Eclipse for the second time in my life :) ).

Then I have opened Eclipse project that was created by somebody else. It is using Java EE (some EJB, Persistence API...). Cannot run this project, there are compile errors - I cannot get it to use EE libraries - it look like this:

No Anotations are known to it and there is no quick fix. Also the project contains Maven dependencies (I have managed to install Maven plugin for Eclipse) and all the classes from dependencies show warnings in the code. Like this:

How do I set up Eclipse to work with this EE project to be able to compile and run it ? Thank you for answers.

EDIT: I'm using Eclipse 2.0.0.2 and I have to use it - its the Rational Team Concept version of Eclipse and version above 2.0.0.2 are not compatible with RTC server.

解决方案

To the point, you've got to include the Java EE API in the buildpath of the project. The Java EE API is in essence the application server, such as for example Oracle Glassfish as you seem to already have.

In Eclipse, open the Servers view at the right bottom box. If there isn't any, then you need to add it. Rightclick there and choose New. The wizard should speak for itself. If there's no option for Sun or Oracle Glassfish, then you've to install the Eclipse plugin separately. In the newer Eclipse versions, you could do that by clicking Download additional server adapters in the top of the wizard and then choosing the Oracle Glassfish Server Tools one. If in older Eclipse version, then you need to install it manually as per the instructions in its homepage.

Once you have the server integrated in Eclipse (or actually already have one), then you should rightclick the dynamic web project and head to the section Targeted runtimes. Select the integrated server there. Rebuild if necessary.

这篇关于设置Eclipse以使用Java EE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆