我在FEIGN-README找到了我可以做的事情:
interface MarketDataRestClient {
@RequestLine("GET /api/v1/depth")
fun getOrderBook(@QueryMap orderBookQuery: OrderBookQuery) : OrderBook
}
OrderBookQuery:
data class OrderBookQuery(val symbol: String, val limit: Int? = 100)
并且Feign应该生成查询参数:/api/v1/depth?symbol={symbol}&limit={limit}
不幸的是,我得到的是:
Exception in thread "main" java.lang.IllegalStateException: QueryMap parameter must be a Map: class OrderBookQuery
at feign.Util.checkState(Util.java:128)
at feign.Contract$BaseContract.parseAndValidateMetadata(Contract.java:126)
at feign.Contract$BaseContract.parseAndValidatateMetadata(Contract.java:64)
at feign.ReflectiveFeign$ParseHandlersByName.apply(ReflectiveFeign.java:146)
at feign.ReflectiveFeign.newInstance(ReflectiveFeign.java:53)
at feign.Feign$Builder.target(Feign.java:198)
at feign.Feign$Builder.target(Feign.java:194)
答案 0 :(得分:2)
此功能将在9.7
中提供。截至撰写本答案时,目前发布的版本为9.6
。如果您不想等待,请克隆存储库并运行构建项目。