spring - Spring getAnnotation 没有解析读取的属性文件
问题描述
配置:
for (Method m : objClz.getDeclaredMethods()) {
if (m.isAnnotationPresent(CountryEnabled.class)) {
GetMapping annotation1 = m.getAnnotation(GetMapping.class);
log.info("{}",annotation1.value());
}
}
控制器:
@GetMapping("${bean.get.endpoint}")
public ResponseEntity getGreeting(@PathVariable String version){
return versionController.findVersionHandler("${bean.get.endpoint}", version, HttpMethod.GET);
}
道具文件:
server.port=8081
bean.get.endpoint=/{version}/greeting
bean.get.endpoint.message=/{version}/greeting/{message}
bean.get.endpoint.message.secondmessage=/{version}/greeting/{message}/{secondmessage}
bean.post.endpoint.message=/{version}/greeting
从配置文件记录:
2020-08-04 22:18:57.492 INFO 21096 --- [ restartedMain] c.e.b.a.country.CountryEnabledConfig : [${bean.get.endpoint}]
似乎正在阅读,[${bean.get.endpoint}]而不是实际值/{version}/greeting
,有没有办法解决它?
解决方案
推荐阅读
- pandas - 熊猫和美丽的汤:打印 href 而不是列的值
- python-3.x - Python 3 中 int(input()) 和 input(int()) 之间的区别
- wordpress - 我可以让 WordPress 在浏览器中显示 wp-admin 的 URL 更漂亮吗?
- javascript - 如何在 VueJS 中创建多个商店过滤器?
- core-data - 我的分段选择器有正常的 Int 值作为标签,这是如何传递到 CoreData 和从 CoreData 传递的?
- sapui5 - SAPUI5,两个日历有自己的id,没有任何共享,setter将无缘无故更改两个日历的月份
- r - 重构和创建 5 x 5 汇总矩阵 r
- amazon-web-services - AWS Cloudformation 创建策略卡住
- java - SimpleJdbcCall 异常:缺少必需的输入参数
- python - 使用 Python 3.5 及更高版本导入目录错误