【问题标题】:Liferay IDE : Transform a maven project to a liferay IDE compatible projectLiferay IDE:将 maven 项目转换为 liferay IDE 兼容项目
【发布时间】:2011-06-09 16:05:28
【问题描述】:

我使用 Maven 创建我的 portlet,并且我正在使用 Liferay IDE(一个基于 Eclipse 的 IDE),但是我不能直接从 Liferay IDE 部署我的项目,因为我的项目不支持这个。 有一种方法可以将 Liferay 的功能添加到项目中,但它不起作用......你能帮忙吗?

【问题讨论】:

    标签: maven liferay liferay-ide


    【解决方案1】:

    Maven archetypes and plugin for Liferay 允许您创建和部署 portlet 项目。

    如果您将项目作为现有 Maven 项目(使用 m2eclipse)导入 Eclipse,那么您可以执行“Run as Maven build”并运行“mvn liferay:deploy”。例如,如果您部署到在 Eclipse 中以调试模式运行的 Tomcat 实例,那么您将能够设置断点等。

    如果您这样做,您甚至可能不需要“Liferay IDE”而不是普通的旧 Eclipse。

    【讨论】:

      【解决方案2】:

      您可能已经看过这个,但我按照本指南开始在我们的项目中使用 Liferay IDE:

      http://www.liferay.com/community/wiki/-/wiki/Main/Liferay+IDE+Getting+Started+Tutorial

      希望对你有帮助。

      【讨论】:

      • 问题不在于创建portlet,而是将Liferay IDE与maven项目(一个portlet但遵循maven的项目架构)一起使用
      【解决方案3】:

      在当前版本的 Liferay IDE (1.2.x) 中,无法将 Liferay IDE 项目方面添加到基于 maven 的项目中。在 Liferay IDE (2.0) 的未来版本中,将支持 Maven。

      现在您只需要使用 ant build.xml 脚本进行部署,或者可能使用支持部署的 liferay maven 插件。

      【讨论】:

        【解决方案4】:

        我知道这是一个老问题,但我想分享这个解决方案,因为我花了一些时间才弄清楚。它是@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 项目。如果您想启动 hook/ext/theme-project,您可以将 -DarchetypeArtifactId 更改为另一个原型。接下来,进入您刚刚创建的名为 YOUR-PORTLET 的项目目录。现在编辑您的 pom.xml 并将其添加到最后的 </project> 之前。

        <properties>
            <liferay.version>6.1.1</liferay.version>
        </properties>
        

        接下来发出命令。 mvn eclipse:eclipse -Dwtpversion=2.0 这就是 eclipse 对自动部署的支持。

        接下来我们需要手动添加一些 TLD 文件。从this Liferay Git repo 获取所有 .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 类和 jsp 文件时,它也会自动同步,因此更改将在几秒钟内刷新时可见。请记住,这需要 Eclipse WTP 扩展和在 eclipse 中配置的 tomcat 服务器。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2023-03-29
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2018-04-18
          • 2012-07-24
          • 2019-01-19
          • 1970-01-01
          相关资源
          最近更新 更多