IBM MobileFirst:在命令行构建期间使用外部 jar 文件
IBM MobileFirst: using external jar files during command line build
我们正在尝试使用 org.JSON.JSONObject 库在适配器端进行一些密集的 json 处理。我们有 Java 类 来处理从 http 适配器接收到的数据。
mobilefirst 6.3.0 and using cli 20150701 build
(最近的).
从 eclipse mobilefirst studio 环境构建时,此 JSON 引用没有问题。
我们正在 ubuntu linux 14.04 中构建此环境。执行
时引用org.JSON.JSONObject..x.jar
文件出错
mfp start or mfp build or mfp deploy
有没有办法在 mfp 启动或 mfp 构建或 mfp 部署期间将此 jar 文件作为类路径引用。
我们需要
mfp -classpath "path/to/json.jar" build
请帮忙。
供适配器使用的 JAR 应添加到文件夹 lib 中的项目服务器目录中。当项目构建时(在 Studio 中或通过 ant 任务),它们将包含在您的项目 WAR 文件中,并且当您部署该项目时 WAR 它将对您的适配器可见。
事实证明,CLI 还不能识别放置在项目 server/lib 文件夹中的 jars。为了使这项工作有效,您可以对以下文件进行简单的编辑:
[cli 安装文件夹]/mobilefirst-cli/node_modules/generator-worklight-server/lib/build.xml
在第 123 行或附近,添加如下所示的第三个文件集元素:
<!-- Classpath for server runtime libraries used when building the WAR -->
<path id="server-classpath">
<fileset dir="${worklight.jars.dir}" includes="worklight-jee-library.jar" />
<fileset dir="${worklight.server.install.dir}/wlp/dev" includes="**/*.jar" />
<!-- add server/lib folder to classpath -->
<fileset dir="${worklight.app.dir}/../server/lib" includes="**/*.jar" />
</path>
之后,运行 'mfp start'(或 'mfp restart' 如果您的服务器已经 运行)将编译您的自定义 Java 代码与任何罐子您添加到类路径中包含的 server/lib 文件夹。
我同意@bjustin_ibm。感谢那。虽然上述方法有效,但还有另一种方法可以做到这一点。
替代黑客
只需将所需的 .jars 添加到以下位置,它会在 mfp 启动期间添加到类路径中
/home/instanceubuntu/.ibm/mobilefirst/6.3.0/server/wlp/dev/spi/third-party
这个解决方案更简单,实际上不需要维护 build.xml 文件。
希望对您有所帮助。
我们正在尝试使用 org.JSON.JSONObject 库在适配器端进行一些密集的 json 处理。我们有 Java 类 来处理从 http 适配器接收到的数据。
mobilefirst 6.3.0 and using cli 20150701 build
(最近的).
从 eclipse mobilefirst studio 环境构建时,此 JSON 引用没有问题。
我们正在 ubuntu linux 14.04 中构建此环境。执行
时引用org.JSON.JSONObject..x.jar
文件出错
mfp start or mfp build or mfp deploy
有没有办法在 mfp 启动或 mfp 构建或 mfp 部署期间将此 jar 文件作为类路径引用。
我们需要
mfp -classpath "path/to/json.jar" build
请帮忙。
供适配器使用的 JAR 应添加到文件夹 lib 中的项目服务器目录中。当项目构建时(在 Studio 中或通过 ant 任务),它们将包含在您的项目 WAR 文件中,并且当您部署该项目时 WAR 它将对您的适配器可见。
事实证明,CLI 还不能识别放置在项目 server/lib 文件夹中的 jars。为了使这项工作有效,您可以对以下文件进行简单的编辑:
[cli 安装文件夹]/mobilefirst-cli/node_modules/generator-worklight-server/lib/build.xml
在第 123 行或附近,添加如下所示的第三个文件集元素:
<!-- Classpath for server runtime libraries used when building the WAR -->
<path id="server-classpath">
<fileset dir="${worklight.jars.dir}" includes="worklight-jee-library.jar" />
<fileset dir="${worklight.server.install.dir}/wlp/dev" includes="**/*.jar" />
<!-- add server/lib folder to classpath -->
<fileset dir="${worklight.app.dir}/../server/lib" includes="**/*.jar" />
</path>
之后,运行 'mfp start'(或 'mfp restart' 如果您的服务器已经 运行)将编译您的自定义 Java 代码与任何罐子您添加到类路径中包含的 server/lib 文件夹。
我同意@bjustin_ibm。感谢那。虽然上述方法有效,但还有另一种方法可以做到这一点。
替代黑客
只需将所需的 .jars 添加到以下位置,它会在 mfp 启动期间添加到类路径中
/home/instanceubuntu/.ibm/mobilefirst/6.3.0/server/wlp/dev/spi/third-party
这个解决方案更简单,实际上不需要维护 build.xml 文件。
希望对您有所帮助。