Gson是Google公司发布的一个开放源代码的Java库,主要用途为序列化Java对象为JSON字符串,或反序列化JSON字符串成Java对象。
<dependencies>
<dependency>
<groupId>org.apache.dubbo.extensions</groupId>
<artifactId>dubbo-serialization-gson</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
</dependency>
</dependencies>
# application.yml (Spring Boot)
dubbo:
protocol:
serialization: gson
或
# dubbo.properties
dubbo.protocol.serialization=gson
# or
dubbo.consumer.serialization=gson
# or
dubbo.reference.com.demo.DemoService.serialization=gson
或
<dubbo:protocol serialization="gson" />
<!-- or -->
<dubbo:consumer serialization="gson" />
<!-- or -->
<dubbo:reference interface="xxx" serialization="gson" />