使用IBM Rational Application Developer 8开发Portlet - Maven集成

来源:互联网 发布:淘宝上买号怎么领取 编辑:程序博客网 时间:2024/04/30 16:07

本文介绍如何设置在IBM Rational Application Developer (RAD) 8中集成Maven以进行Portlet的开发。

第1步 - 安装IBM Rational Application Developer V8.0.4

参见 - 使用IBM Rational Application Developer 8开发Portlet - 开发环境

第2步 - 安装 m2eclipse-wtp release 1.0.100

1) 在RAD中选择菜单 Window - Preferences - Install/Update - Available Software Sites, 选择以下站点,

* http://download.eclipse.org/eclipse/updates/3.6
* http://download.eclipse.org/webtools/repository/helios 



2) 在RAD中选择菜单Help -> Install New Software, 增加以下站点:

http://download.jboss.org/jbosstools/updates/m2eclipse-wtp

选择以下组件:

* Maven Integration for Eclipse
* Maven Integration for WTP
* Maven Integration for Eclipse Extras - m2e connector for maven archiver pom properties



第3步 - 安装 m2e connectors以连接software configuration management (SCM)

我使用SVN, 首先从http://subclipse.tigris.org/update_1.6.x安装Subclipse V1.6.X,然后在RAD中选择菜单Window - Preferences - Maven - Discovery, 点击Open Catalog以安装m2e-subclipse connector.




第4步 - 设置Java EE and Maven preference

1)在RAD中选择菜单Window - Preferences - Java EE - Project, 清除"Add project to an EAR"选择框.


2)在RAD中选择菜单Window - Preferences - Maven - WTP integration, 清"Generate application.xml under the build directory"选择框.


第5步 - 在RAD workspace中创建或导入Maven项目

使用RAD "Checkout Maven projects from SCM"或"Import Existing Maven Projects"向导在RAD workspace中导入Maven项目.

我一般在Maven项目中包含三个模块: core, webappear. 当RAD导入该Maven项目时, m2eclipse-wtp会根据maven模块的类型生成相应的Eclipse项目和设置文件。



第6步 - 设置EAR项目属性

只有在设置了相关的EAR项目属性之后,才可以在RAD中使用debug/run on serverWAS deployment descriptor编辑等功能

1)鼠标右键EAR项目并选择Properties - Project Facets, 选择"Websphere Application(Co-existence)""Websphere Application(Extended)"选择框, 并选择相应的WAS server版本



2)鼠标右键EAR项目并选择Properties - Targeted Runtimes, 选择"Websphere Portal"选择框.



以上就是集成Maven和RAD的基本步骤。

问题和解决方法

问题 - 右击EAR项目的弹出菜单中没有Open WebSphere Application Deployment选项

解决方法 - 在ear模块的POM文件中, 设置maven-ear-plugin/configuration/version值为5或以上.

<plugin>  <groupId>org.apache.maven.plugins</groupId>  <artifactId>maven-ear-plugin</artifactId>  <version>2.6</version>  <configuration>    <!-- generate application.xml version 5, to enable RAD to edit WAS deployment descriptor -->    <version>5</version>      <modules>      <webModule>        <groupId>${project.groupId}</groupId>        <artifactId>demo-webapp</artifactId>        <contextRoot>MavenDemoPortlet</contextRoot>      </webModule>    </modules>  </configuration></plugin>

问题 - 右击EAR项目并点击Open WebSphere Application Deployment报错Could not open the editor: An unexpected exception was thrown.

解决方法 - 打开ear项目的settings/org.eclipse.wst.common.component文件, 检查wb-moduledeploy-name属性值是否和Eclipse项目名相同. 如果不同的话,使用以下方法之一来修改.

方法1)在ear模块的POM文件中, 添加build/finalName属性, 其值为ear模块的artifactId,

<build>  <!--     same as the artifactId, which is the RAD project name, and also the        deploy-name defined in settings/org.eclipse.wst.common.component      -->  <finalName>demo-ear</finalName>  ...</build>


方法2) 在项目导入时, 使用Advanced setting, 在Name template中选择[artifactId]-[version].

问题 - Portlet Run/Debug on Server报错EJPPG0024I: Web application with context root XXX is deployed in the application server but not registered with portal.

解决方法 - 检查webapp项目settings/org.eclipse.wst.common.component文件, 检查wb-modulecontext-root属性是否和ear maven-ear-plugin的contextRoot相同, 如果不同的话, 可以修改ear POM,也可以通过在webapp模块的POM文件中定义m2eclipse.wtp.contextRootbuild/finalName属性以修改settings/org.eclipse.wst.common.component文件、

<properties>  <!-- this must be same as the contextRoot defined in the ear module-->  <m2eclipse.wtp.contextRoot>MavenDemoPortlet</m2eclipse.wtp.contextRoot></properties>


	
				
		
原创粉丝点击