# mill **Repository Path**: ispace-code/mill ## Basic Information - **Project Name**: mill - **Description**: 第三方 接口访问 工具。以 RPC 方式访问第三方接口。 经过对服务类节点,协议和策略 的配置,完成对不同 第三方(接口提供者),不同协议(http、https、ftp、sftp)、不同报文结构(策略处理)使用相同的Java 代码调用方式。 - **Primary Language**: Java - **License**: MulanPSL-1.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 9 - **Forks**: 3 - **Created**: 2019-10-23 - **Last Updated**: 2023-11-14 ## Categories & Tags **Categories**: rpc **Tags**: None ## README # mill #### 介绍 使用注解标记字段、方法、策略以 RPC 方式访问第三方接口。 经过对服务类节点,协议和策略 的配置,完成对不同 第三方(接口提供者),不同协议(http、https、ftp、sftp)、不同报文结构(策略处理)使用相同的Java 代码调用方式。 主要使用 注解、反射、SPI等实现。 ``` #### 工程结构 mill ├── mill-common -- 公共包 ├── mill-core -- 核心代码逻辑 ├── mill-demo -- demo ├── mill-spring-boot -- Spring boot 组件 ├ ├── mill-spring -- Spring 依赖代码 ├ ├── mill-spring-boot-autoconfigure -- springboot 自动配置 ├ └── mill-spring-boot-starter -- springboot 自动依赖 ├── mill-support -- 第三方 依赖 和 逻辑支持 └── mill-test -- 测试 ``` #### 使用说明 1、springboot autoconfigure。 @MillScan({ "cn.mill.demo.postcode", "cn.mill.demo.weixin", "cn.mill.demo.open" }) 注解扫描声明接口类的包。 Spring @Autowired 注解直接引用 相关 接口。 2、API 方式 声明 接口类 @ServiceDefine(name = "WeatherApi", node = "weather", protocol = "http", strategy = "xml") public interface WeatherApi { @HttpDefine(method = HttpMethod.GET) @MethodMapping(value = "/WeatherApi?city={city}", tip = "通过城市名字获得天气数据") public Report weather(@Property(name = "city", tag = Tag.URL) String city); } api 调用 WeatherApi weatherApi = Mill.factory(WeatherApi.class); Report weather = weatherApi.weather("北京"); System.out.println(weather.toString()); 3、协议和策略扩展接口使用SPI 实现,需继承 cn.mill.common.Protocol、cn.mill.common.Strategy 接口,并配置SPI扩展配置文件。 4、默认读取类根路径下节点配置文件 mill.properties