Service Builder不编译依赖于IVY jar的代码



我有一个基本程序,其中有一个用于服务构建器的简单实体,没有用于web服务调用的属性。我在本地依赖于包含在javax.ws.rs-api-2.0.1.jar中的javax.ws.rs库。

在IDE中,代码不会显示任何错误。我可以在项目资源管理器窗口中看到Ivy依赖项。然而,当我调用buildservices命令时,它无法使用外部jar中的Classes编译代码。

在我的应用程序中依赖jar时,我是否遗漏了一个步骤?这不应该自动链接吗?

蚂蚁输出:

   [javac] Compiling 4 source files to C:liferayliferay-developer-studioliferay-plugins-sdk-6.2portletsmyApp-portal-portletdocrootWEB-INFservice-classes
    [javac] ----------
    [javac] 1. ERROR in C:liferayliferay-developer-studioliferay-plugins-sdk-6.2portletsmyApp-portal-portletdocrootWEB-INFservicecomexamplemyAppportalserviceExternalApiLocalService.java (at line 69)
    [javac]     public javax.ws.rs.client.WebTarget myAppRestApi();
    [javac]            ^^^^^^^^^^^^^^^^^^
    [javac] javax.ws.rs.client cannot be resolved to a type
    [javac] ----------
    [javac] 2. ERROR in C:liferayliferay-developer-studioliferay-plugins-sdk-6.2portletsmyApp-portal-portletdocrootWEB-INFservicecomexamplemyAppportalserviceExternalApiLocalService.java (at line 71)
    [javac]     public javax.ws.rs.client.WebTarget myAppRegisterService();
    [javac]            ^^^^^^^^^^^^^^^^^^
    [javac] javax.ws.rs.client cannot be resolved to a type
    [javac] ----------
    [javac] 3. ERROR in C:liferayliferay-developer-studioliferay-plugins-sdk-6.2portletsmyApp-portal-portletdocrootWEB-INFservicecomexamplemyAppportalserviceExternalApiLocalService.java (at line 73)
    [javac]     public javax.ws.rs.client.WebTarget myAppValidPaService();
    [javac]            ^^^^^^^^^^^^^^^^^^
    [javac] javax.ws.rs.client cannot be resolved to a type
    [javac] ----------
    [javac] ----------
    [javac] 4. ERROR in C:liferayliferay-developer-studioliferay-plugins-sdk-6.2portletsmyApp-portal-portletdocrootWEB-INFservicecomexamplemyAppportalserviceExternalApiLocalServiceClp.java (at line 127)
    [javac]     public javax.ws.rs.client.WebTarget myAppRestApi() {
    [javac]            ^^^^^^^^^^^^^^^^^^
    [javac] javax.ws.rs.client cannot be resolved to a type
    [javac] ----------
    [javac] 5. ERROR in C:liferayliferay-developer-studioliferay-plugins-sdk-6.2portletsmyApp-portal-portletdocrootWEB-INFservicecomexamplemyAppportalserviceExternalApiLocalServiceClp.java (at line 146)
    [javac]     return (javax.ws.rs.client.WebTarget)ClpSerializer.translateOutput(returnObj);
    [javac]             ^^^^^^^^^^^^^^^^^^
    [javac] javax.ws.rs.client cannot be resolved to a type
    [javac] ----------
    [javac] 6. ERROR in C:liferayliferay-developer-studioliferay-plugins-sdk-6.2portletsmyApp-portal-portletdocrootWEB-INFservicecomexamplemyAppportalserviceExternalApiLocalServiceClp.java (at line 150)
    [javac]     public javax.ws.rs.client.WebTarget myAppRegisterService() {
    [javac]            ^^^^^^^^^^^^^^^^^^
    ...........................etc
BUILD FAILED
C:liferayliferay-developer-studioliferay-plugins-sdk-6.2build-common-plugin.xml:262: The following error occurred while executing this line:
C:liferayliferay-developer-studioliferay-plugins-sdk-6.2build-common.xml:634: Compile failed; see the compiler error output for details.

ivy.xml:

<?xml version="1.0"?>
<ivy-module
    version="2.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd"
>
    <info module="portlet_liferay_faces_alloy_tmpl" organisation="com.liferay" />
    <dependencies defaultconf="default">
        ...
        <dependency name="jersey-common" org="org.glassfish.jersey.core" rev="2.12" transitive="true" />
        <dependency name="jersey-client" org="org.glassfish.jersey.core" rev="2.12" transitive="true" />
        <dependency name="html-json" org="org.glassfish.jersey.media" rev="2.12" transitive="true"/>
    </dependencies>
</ivy-module>

谨致问候,代码。

您几乎自己回答了这个问题,但这并不明显:当servicebuilder运行时,它会执行一些需要与项目的类路径一起运行的java代码:servicebuilder会编译/检查您的代码,以生成适当的接口等。

因此,您还需要将项目的依赖项注入到servicebuilder流程中。当您从IDE运行servicebuilder时,它很可能正在运行Ant任务,该任务将从Web应用程序中获取所有明显的(对Ant)依赖关系(例如,它在WEB-INF/lib和appserver的全局类路径中找到的内容)。Ant进程不会扫描任何ivy、maven或其他构建工具的依赖声明——不幸的是,您将不得不两次添加此依赖。

相关内容

  • 没有找到相关文章

最新更新