RPC API shared interface

Generate Feign interfaces, DTOs, path constants and API auto-configuration.

Module responsibilities

lodsve-archetype-rpc-api generates an API package shared by both service parties, including UserRpcApi, request and response DTO, PathConstant, DemoRpcApiAutoConfiguration, and META-INF/spring.factories.

API projects are used for HTTP applications that are dependent on other projects and are not started independently. There is no need to set port or contextPath.

Generate API

finish first RPC Guide Install the template in and set up ARCHETYPE_VERSION and LODSVE_BOOT_VERSION in the same terminal. The following commands are executed in the common parent directory of the three business projects.

: "${ARCHETYPE_VERSION:?Install the RPC archetypes and specify their version first}"
: "${LODSVE_BOOT_VERSION:?Set LODSVE_BOOT_VERSION first}"

mvn archetype:generate \
  -DinteractiveMode=false \
  -DarchetypeGroupId=com.lodsve.archetype \
  -DarchetypeArtifactId=lodsve-archetype-rpc-api \
  -DarchetypeVersion="$ARCHETYPE_VERSION" \
  -DgroupId=com.example \
  -DartifactId=demo-api \
  -Dversion=1.0.0-SNAPSHOT \
  -Dpackage=com.example.rpc \
  -Dauthor=developer \
  -DbootVersion="$LODSVE_BOOT_VERSION" \
  -DserverAppName=demo-server \
  -DserverContextPath=/demo-server

Service positioning

UserRpcApi uses @FeignClient. The service name comes from serverAppName and the path prefix is a combination of serverContextPath and the template’s /rpc/feign/user. When modifying the name or context path of the Server, the API contract needs to be modified simultaneously.

Install shared packages

First check the dependencies and warehouse configuration of generated POM. For check items, see Quickstart, and then execute:

cd demo-api
./mvnw clean install
cd ..

Next Generate Server.

API template source code

Architecture diagram