1

I'm using MobileFirst Platform v7.0 on OSX. I tend to switch back and forth between Studio and the CLI depending on what I am doing.

I found that a Java adapter created through the command line will not build using Studio without some manual configuration. I had this question 95% typed when I found a solution so I decided to post it anyway in hopes it might help others.

To duplicate:

  1. Create a workspace, MFP project and Hybrid app in Studio
  2. In Studio, create a Java adapter named Studio with package com.studio
  3. Deploy the Studio adapter. Adapter builds and deploys successfully.
  4. Open a terminal and navigate to the adapters directory of the project
  5. From CLI, create a Java adapter named CLI with the following command: mfp adapter add CLI -t java -p com.cli
  6. Back in Studio, refresh and Deploy the CLI adapter. Observe error 'com.cli.CLIApplication' was not found.
4

1 回答 1

2

我发现问题是当使用 CLI 创建适配器时,源文件夹适配器/CLI/src 没有添加到项目的 Java 构建路径中。

在尝试手动将源文件夹添加到构建路径时,我发现 CLI 目录中没有创建“bin”文件夹。如果我没有手动创建 bin 文件夹并将其设置为源文件夹的输出文件夹,我会收到错误JAXRS Application class: 'com.cli.CLIApplication' must extend javax.ws.rs.Application

所以解决方案是:

  1. 在 Studio 中,编辑项目的 Java 构建路径(右键单击项目,构建路径 > 配置构建路径)。
  2. 选择Source选项卡,然后单击Add Folder
  3. 选择adapters/CLI/src并单击OK
  4. 选择新条目下的输出文件夹,然后单击编辑
  5. 输入适配器/CLI/bin

适配器现在应该在 Studio 或 CLI 中构建。

于 2015-04-15T16:43:57.217 回答