使用 EGit 快速创建适配器模块的 EJB & EAR 项目

介绍

为 PI 创建适配器模块需要一些工作,因为我们必须在 NWDS 中创建 EJB 和 EAR 项目,并设置所有必要的构建路径和部署描述符文件。

当我开始使用 EGit/Git 来管理我的 NWDS 项目时,我发现它可以通过不同的方式来增强我的工作流程。其中一个领域是设置模板EJB和EAR项目,用于自定义适配器模块。已经有其他方法,例如下面的博客是将模板用于适配器模块项目。

使用 EJB、EAR 模板构建适配器模块的简单步骤

使用 EGit 的好处是,一旦模板克隆到 NWDS 中,项目将自动由 Git 进行版本管理。

以下是有关如何使用 GitHub 中的模板内容快速设置适配器模块项目的步骤。

先决条件

以下步骤以 NWDS 7.31 为基础。首先需要安装和配置 EGit,如以下博客的安装和初始配置部分所述。

在 NWDS 中使用 EGit 进行 Java 源代码管理

步骤

步骤 1 - 将 Git 存储库从 GitHub 克隆到 NWDS

通过下面的链接转到 Git 存储库,然后选择 Copy to clipboard(复制到剪贴板)。

engswee/pi-module-template ·GitHub的

在 NWDS 中,切换到 Git 透视图 - 窗口>打开透视图 > 其他 > Git 存储库浏览

单击 Clone Git Repository 按钮

将弹出一个窗口,其中包含 GitHub URL 详细信息的预填充值。接受默认值,然后单击 Next。

它将加载 GitHub 分支详细信息。再次单击 Next。

Finally, it will prompt for a destination of the local Git repository. Browse to the appropriate folder and select Finish.

The contents will be downloaded from GitHub to the local Git repository. The screenshot below shows the new (arbitrarily named) Git repository new-module.

Step 2 - Import EJB and EAR projects

The contents in the Git repository already consists of the template EJB and EAR projects for a custom adapter module. This content will need to be imported into NWDS's project explorer.

Right click on the Git repository and select Import Projects.

Select Import existing projects and click Next.

Select both EJB and EAR projects and click Finish.

After import has completed. Switch to the Java EE perspective and both the EJB and EAR projects will be listed in the Project Explorer.

Step 3 - Refactor project contents

Now just refactor the project contents according to the development naming conventions and requirements.

Rename EAR project.

Update provider name in application-j2ee-engine.xml in EAR project.

Rename EJB project.

Rename package in EJB project.

Rename EJB 3.0 Session Bean.

Rename ejb-j2ee-engine.xml deployment descriptor. Ensure that this matches the name of the session bean above.

Rename ejb-jar.xml deployment descriptor. Ensure that the name and package path matches above changes.

Step 4 - Commit initial content to Git (Optional)

Once all the changes have been done, optionally commit an initial version to the Git repository.

这样,EJB 和 EAR 项目现在就可以根据项目需求进行进一步开发了。

结论

通过这个简单易行的步骤,我们可以快速建立一个新的自定义适配器模块项目,并直接进入设计和开发细节。我们不再需要记住正确设置项目配置的细节,这可能非常重复(有时我也发现在涉及如此多的屏幕时很难记住)。

克隆 Git 存储库后,只需几个重构步骤,项目就可以进行开发了。此外,它还受益于已经被 Git 跟踪。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值