2011-06-09 226 views

回答

1

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

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

您甚至可能不需要“Liferay IDE”而不是普通的旧式Eclipse if你做这个。

1

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

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

0

我知道这是一个老问题,但我想分享这个解决方案,因为花了我一些时间才弄明白。它是@Charles Brooking公认的答案的延伸。在我看来这更好。如果您希望在您的maven liferay项目中使用Eclipse WTP自动部署,而不是执行并等待专家构建和部署,那么您就是这样做的。

步入从控制台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更改为另一个原型。接下来,进入您刚刚创建的项目dir,称为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.xml中的WEB-INF您的项目中。现在你可以去Eclipse并做File, Import, General, "Existing projects into Workspace"并选择你的新项目。现在您可以右键点击项目并选择Run, "Run on server"。现在您可以看到您的项目已在Servers-tab中部署和同步。当你保存你的java-classes和jsp-files时,它也会自动同步,以便在几秒钟内刷新刷新。请记住,这需要eclipse中的Eclipse WTP扩展和配置的tomcat服务器。