public void setValues() throws NoSuchFieldException, IllegalAccessException {
for (Annotation annotation : TestController.class.getMethods()[0].getAnnotations()) {
InvocationHandler h = Proxy.getInvocationHandler(annotation);
Field hField = h.getClass().getDeclaredField("memberValues");
hField.setAccessible(true);
Map memberValues = (Map) hField.get(h);
memberValues.entrySet().forEach(item -> {
Map.Entry entry = (Map.Entry)item;
if (entry.getValue() instanceof String && ((String)entry.getValue()).matches("^\\$\\{.*\\}$")){
memberValues.put(entry.getKey(), stringValueResolver.resolveStringValue((String) entry.getValue()));
}
});
}
}
根据配置文件动态设置注解值
最新推荐文章于 2023-07-22 18:02:22 发布