dubbo-website icon indicating copy to clipboard operation
dubbo-website copied to clipboard

使用 Protobuf(IDL) 开发 triple 通信服务

Open a2501521908 opened this issue 4 months ago • 0 comments

你好,我在使用dubbo的trip协议过程中多参数遇到了问题

如果出现一个方法多个参数, queryLearningTime(String channelCode, String crCode) 且不是DTO形式呈现,则会出现问题

通过trip访问会报错: Name for argument of type [class java.lang.String] not specified, and parameter name information not available via reflection. Ensure that the compiler uses the -parameters flag

这是因为trip仅是dubbo上层协议,无法做到一对一参数的映射。在jvm中,这个函数就变成了这样: queryLearningTime(java.lang.String, java.lang.String);

这样看两个都是String而且没有名字,协议无法找到序列化的参数,所以需要在maven中添加-parameters参数

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.1</version>
    <configuration>
        <source>${java.version}</source>
        <target>${java.version}</target>
        <encoding>UTF-8</encoding>
        <!-- 添加以下配置后,maven在编译过程中会保留参数名 -->
        <compilerArgs>
            <arg>-parameters</arg>
        </compilerArgs>
    </configuration>
</plugin>

是否可以在 https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/tasks/protocols/triple/idl/ 页增加一些提示?

Image

a2501521908 avatar Aug 05 '25 07:08 a2501521908