【发布时间】:2020-05-25 12:30:44
【问题描述】:
我多次浏览链接:How to pass a Map<String, String> with application.properties 和其他相关链接,但仍然无法正常工作。
我正在使用 Spring Boot 和 Spring REST 示例。链接问题:How to by default execute the latest version of endpoint in Spring Boot REST?。
我已经创建了类似这样的映射并简单地阅读映射
get.customers={GET: '/app-data/customers', VERSION: 'v1'}
post.customers={POST: '/app-data/customers', VERSION: 'v1'}
get.customers.custId={GET: '/app-data/customers/{custId}', VERSION: 'v2'}
代码:
private String resolveLastVersion() {
// read from configuration or something
return "2";
}
代码:
@Component
@ConfigurationProperties
@PropertySource("classpath:restendpoint.properties")
public class PriorityProcessor {
private final Map<String, String> priorityMap = new HashMap<>();
public Map<String, String> getPriority() {
return priorityMap;
}
}
代码:
【问题讨论】:
标签: spring spring-boot spring-rest api-versioning