我使用 Maven 创建我的 portlet,并且我正在使用 Liferay IDE(一个基于 Eclipse 的 IDE),但是我不能直接从 Liferay IDE 部署我的项目,因为我的项目不支持这个。有一种方法可以将 Liferay 的功能添加到项目中,但它不起作用......你能帮忙吗?
4 回答
在当前版本的 Liferay IDE (1.2.x) 中,无法将 Liferay IDE 项目方面添加到基于 maven 的项目中。在 Liferay IDE (2.0) 的未来版本中,将支持 Maven。
现在,您只需要使用 ant build.xml 脚本进行部署,或者可能使用可能支持部署的 liferay maven 插件。
您可能已经看过了,但我按照本指南开始在我们的项目中使用 Liferay IDE:
http://www.liferay.com/community/wiki/-/wiki/Main/Liferay+IDE+Getting+Started+Tutorial
希望能帮助到你。
Liferay的Maven 原型和插件允许您创建和部署 portlet 项目。
如果您将项目作为现有 Maven 项目(使用 m2eclipse)导入 Eclipse,那么您可以执行“Run as Maven build”并运行“mvn liferay:deploy”。例如,如果您部署到在 Eclipse 中以调试模式运行的 Tomcat 实例,那么您将能够设置断点等。
如果您这样做,您甚至可能不需要“Liferay IDE”而不是普通的旧 Eclipse。
我知道这是一个老问题,但我想分享这个解决方案,因为我花了一些时间才弄清楚。它是@Charles Brooking 接受的答案的扩展。在我看来,这更好。如果您更愿意在您的 maven liferay 项目中使用 Eclipse WTP 自动部署,而不是执行和等待 maven 构建和部署,那么您就是这样做的。
从控制台进入您的 Eclipse 工作区并运行
mvn archetype:generate -DarchetypeGroupId=com.liferay.maven.archetypes -DarchetypeArtifactId=liferay-portlet-archetype -DarchetypeVersion=6.1.1 -DgroupId=YOURGROUPID -DartifactId=YOUR-PORTLET -Dversion=1.0.0-SNAPSHOT
这将创建您的 mave portlet 项目。如果你想开始一个钩子/扩展/主题项目,你可以更改-DarchetypeArtifactId
为另一个原型。接下来,进入您刚刚创建的名为 YOUR-PORTLET 的项目目录。现在编辑您的 pom.xml 并将其添加</project>
到最后。
<properties>
<liferay.version>6.1.1</liferay.version>
</properties>
接下来发出命令。mvn eclipse:eclipse -Dwtpversion=2.0 这是 eclipse 对自动部署的支持。
接下来我们需要手动添加一些 TLD 文件。从此Liferay Git存储库中获取所有 .tld 文件 或在其他地方搜索它们。将它们放在项目中的 WEB-INF/tld/ 中并添加
<jsp-config>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/tld/c.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://liferay.com/tld/aui</taglib-uri>
<taglib-location>/WEB-INF/tld/aui.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/portlet_2_0</taglib-uri>
<taglib-location>/WEB-INF/tld/liferay-portlet.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://liferay.com/tld/portlet</taglib-uri>
<taglib-location>/WEB-INF/tld/liferay-portlet-ext.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://liferay.com/tld/security</taglib-uri>
<taglib-location>/WEB-INF/tld/liferay-security.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://liferay.com/tld/theme</taglib-uri>
<taglib-location>/WEB-INF/tld/liferay-theme.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://liferay.com/tld/ui</taglib-uri>
<taglib-location>/WEB-INF/tld/liferay-ui.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://liferay.com/tld/util</taglib-uri>
<taglib-location>/WEB-INF/tld/liferay-util.tld</taglib-location>
</taglib>
到项目内 WEB-INF 中的 web.xml。现在您可以转到 Eclipse 并File, Import, General, "Existing projects into Workspace"
选择您的新项目。现在您将能够右键单击项目并选择Run, "Run on server"
. 现在您可以看到您的项目已在 Servers 选项卡中部署和同步。当您保存 java-classes 和 jsp-files 时,它也将自动同步,因此更改将在几秒钟内刷新时可见。请记住,这需要 Eclipse WTP 扩展和在 eclipse 中配置的 tomcat 服务器。