将 Liferay portlet 导入 Eclipse IDE
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/609798/
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
Importing Liferay portlet into Eclipse IDE
提问by Juri
I have a question regarding the development of liferay portlets using the liferay plugin SDK. My question goes mainly in the setup of the development IDE. The suggested one would be to use Netbeans IDE which I also tried out, but it appears to run very slowly on my machine while Eclipse is quite performant. The setup for Netbeans IDE is the following
我有一个关于使用 liferay 插件 SDK 开发 liferay portlet 的问题。我的问题主要在于开发 IDE 的设置。建议使用我也尝试过的 Netbeans IDE,但它在我的机器上运行速度似乎很慢,而 Eclipse 的性能却非常好。Netbeans IDE 的设置如下
- Go to the directory \portlets
- Run the create.bat (or sh file depending on the OS) to create a new sample portlet
- Run Netbeans IDE, create a new "Java free form project" and point it to the directory of the created sample portlet
- 转至目录 \portlets
- 运行 create.bat(或 sh 文件,具体取决于操作系统)以创建新的示例 Portlet
- 运行 Netbeans IDE,创建一个新的“Java 自由格式项目”并将其指向创建的示例 portlet 的目录
That's it, pretty simple.
就是这样,很简单。
For the mentioned reasons above (and because I'm a lot more familiar with Eclipse) I'd like to import the project into Eclipse the same way. Is there a way for doing it without having to change too much in the original structure of the created sample portlet and the according build.xml (ant file)?? I tried already to create a new project out of the build.xml ant file of the created sample portlet, however in this way it doesn't include me the source code.
由于上述原因(并且因为我对 Eclipse 更加熟悉),我想以相同的方式将项目导入 Eclipse。有没有一种方法可以在不必对创建的示例 portlet 的原始结构和相应的 build.xml(ant 文件)进行太多更改的情况下执行此操作?我已经尝试从创建的示例 portlet 的 build.xml ant 文件中创建一个新项目,但是通过这种方式它不包含我的源代码。
I didn't also find great tutorials on the web... Could someone help me with this, pointing out online tutorials or give me some hints.
我也没有在网上找到很棒的教程...有人可以帮我解决这个问题,指出在线教程或给我一些提示。
Thanks
谢谢
回答by Lorgarn
I know your pain. Starting to work with Liferay needs much time. I you do not want to edit the existing source, but only crate your own portlets, you can download the plugins SDK from the 'Additional Files' section on the Liferay website. This provides ant scripts, to create a simple JSR compliant portlet, and to create all necessary things, to create a sound Eclipse project, for example:
我知道你的痛苦。开始使用 Liferay 需要很多时间。如果您不想编辑现有源代码,而只想创建自己的 portlet,您可以从 Liferay 网站的“附加文件”部分下载插件 SDK。这提供了 ant 脚本,以创建一个简单的 JSR 兼容的 portlet,并创建所有必要的东西,以创建一个健全的 Eclipse 项目,例如:
ant -Dportlet.name=<project name> -Dportlet.display.name="<portlet title>" create
Than cd into the directory of your created portlet an do:
比 cd 进入您创建的 portlet 的目录并执行以下操作:
ant setup-eclipse
After that you should be able to create a new project from the sources in that directory in Eclipse, which can then be deployed via another ant script to the running tomcat instance. If you already know somthing about portlet programming, you shoud be pretty much settled now. If not, try to find documentation about JSR portlet programming first, before looking into Liferay specifig portlet development.
之后,您应该能够从 Eclipse 中该目录中的源创建一个新项目,然后可以通过另一个 ant 脚本将其部署到正在运行的 tomcat 实例。如果您已经对 portlet 编程有所了解,那么现在您应该已经基本掌握了。如果没有,请先尝试查找有关 JSR portlet 编程的文档,然后再查看 Liferay 特定的 portlet 开发。
回答by gamerson
Liferay has now released an official set of Eclipse plugins that support portlet development. Here is the installation guide for installing the eclipse plugins:
Liferay 现在已经发布了一组支持 portlet 开发的官方 Eclipse 插件。以下是安装 eclipse 插件的安装指南:
Liferay IDE Installation Guide
Also there is a getting started guide that shows what to do after installation to actually setting up your first portlet project.
此外,还有一个入门指南,显示了在安装之后如何实际设置您的第一个 portlet 项目。
Liferay IDE uses the Plugins SDK from Liferay under the covers to do all the work. If you already have existing projects that you created with the Plugins SDK those can be imported into Liferay IDE as well.
Liferay IDE 在幕后使用 Liferay 的 Plugins SDK 来完成所有工作。如果您已经有使用 Plugins SDK 创建的现有项目,这些项目也可以导入 Liferay IDE。
回答by naveen
you can find the tutorial for deploying liferayin eclipse
你可以找到在eclipse中部署liferay的教程
http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Development+Environment+(Windows)
http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Development+Environment+(Windows)
回答by david a.
No clue about Liferay's specifics, but in general, I'd do this:
不知道 Liferay 的具体细节,但总的来说,我会这样做:
- Follow the steps 1 and 2 from your NB setup list
- Create a new Dynamic web project (or a Java project if you don't need the web project's features) in Eclipse
- Import the contents of sample portlet directory by doing Import -> File system in Eclipse
- Adjust the project's Java source directory to point to the generated sample portlet source directory (that should now appear in your project)
- Adjust classpath of the project, point it to LR lib folders, ...
- If there's a generated build.xml, check if it can be used to deploy to LR, or to produce builds.
- 按照 NB 设置列表中的步骤 1 和 2
- 在 Eclipse 中创建一个新的动态 Web 项目(如果不需要 Web 项目的功能,则创建一个 Java 项目)
- 通过在 Eclipse 中执行 Import -> File system 导入示例 portlet 目录的内容
- 调整项目的 Java 源目录以指向生成的示例 portlet 源目录(现在应该出现在您的项目中)
- 调整项目的类路径,将其指向 LR lib 文件夹,...
- 如果有生成的 build.xml,请检查它是否可用于部署到 LR 或生成构建。
回答by John P. Fisher
As of March 2011, there is some official Liferay support for NetBeans and as noted before, there is official support for Eclipse ( In the Marketplace). The Documentarian uses Eclipse himself, though many examples just use the Plugins-SDK with shell scripts, ant scripts and no IDE.
截至 2011 年 3 月,有一些对 NetBeans 的官方 Liferay 支持,如前所述,有对 Eclipse 的官方支持(在市场中)。Documentarian 本人使用 Eclipse,尽管许多示例仅使用带有 shell 脚本、ant 脚本且没有 IDE 的 Plugins-SDK。
We are fighting with Liferay on Eclipse, Eclipse seems buggy and unpredictable, but we are also new to J2EE and Eclipse ( so discount this last comment a bit), and I have our portlet files setup in a separate area for SVN, requiring a refactor-move, refactor is definitely buggy.
我们正在 Eclipse 上与 Liferay 进行斗争,Eclipse 似乎有缺陷且不可预测,但我们也是 J2EE 和 Eclipse 的新手(因此对最后一条评论稍作打折),并且我在单独的区域为 SVN 设置了 portlet 文件,需要重构-move,重构肯定有问题。
You should be aware that there is a book for developers on the way from the official documentarian - we've bought the early release and found it useful. He does cover some IDE issues. See Manning press.
您应该知道官方纪录片中有一本面向开发人员的书 - 我们已经购买了早期版本并发现它很有用。他确实涵盖了一些 IDE 问题。见曼宁出版社。
The Liferay sample portlets ( there are many) are not set up for Eclipse projects, and you'll have to import some java files and jump through some Eclipse hoops to get them into a running Eclipse project you can develop.
Liferay 示例 portlet(有很多)不是为 Eclipse 项目设置的,您必须导入一些 java 文件并跳过一些 Eclipse 箍,以将它们放入可以开发的正在运行的 Eclipse 项目中。