在Spring中编写此代码,然后尝试使用自定义注释,该注释将从方法的参数中获取值并对其执行一些逻辑。 但这是行不通的。最终打印出我传入的String值,而不是变量的值。
示例变量名为name,其值为“ Dan”。当我传入参数时,它最终打印出“名称”而不是“丹”。 如果我在Spring中对Cacheable注释执行相同的操作,则效果很好。使用Intellij甚至基于ide的亮点,当我将其传递给@Cacheable时似乎可以识别该参数,但对于我的自定义批注则不然。请告知我在做什么错。
我的自定义注释
@CustomAnnot(key = "#key")
public Object getObj(String key) {
return null;
}
实施注释。当我期望“ Dan”时,这会错误地打印出“ #key”
@Cacheable(key = "#key")
public Object getanotherObj(String key) {
return null;
}
传递相同表达式的示例可缓存。
@Around("@annotation(CustomAnnot)")
public Object get(ProceedingJoinPoint pjp,CustomAnnot customAnnot) throws Throwable {
String key = customAnnot.key();
System.out.println(key);
}
相信此代码不会引起任何问题。只是添加它以防万一。使用注释重定向到进行打印的Aspect类,在该类中我验证它打印错误。
ggplot(data=df57melt) +
geom_col(aes(x=as.factor(variable),y = value,fill = as.factor(cellType),color = ORR,group=cellType),position = position_dodge(),size = 2)+
scale_fill_grey()