Spring AOP 泛型类型 [英] Spring AOP Generic Typing
问题描述
我是 Spring 的新手,我遇到了一个方面的问题.切入点是一个使用泛型类型的接口:
I am new to Spring and I am running into a problem with an aspect. The pointcut is an interface that uses generic typing:
public interface DaoJdbc<T> {
public void create(T input);
public T read(int id);
public void update(T s);
public void delete(int id);
public void getDailyMessage();
}
这是我的方面:
<aop:aspect ref="security">
<aop:pointcut id="passwordNeeded"
expression="execution(* com.user.service.DaoJdbc.*(..))" />
<aop:before pointcut-ref="passwordNeeded" method="check" />
</aop:aspect>
该方面适用于 delete()
,但不适用于 create()
.如果我使用 DaoJdbc 的实现而不是接口本身(我不想这样做),它将适用于create()".我可以假设这是一个问题,因为 update()
使用泛型类型而 delete()
没有.有什么办法可以让我使用界面来工作吗?提前致谢.
The aspect will work for delete()
, but not for create()
. It will work for 'create()' if I use an implementation of DaoJdbc, instead of the interface itself (which I do not want to do). I can assume this is an issue with the fact that update()
uses a generic type and delete()
does not. Is there any way I could get this to work using the interface? Thanks in advance.
推荐答案
找到解决方案,需要加号来表示泛型.
Found the solution, a plus sign is needed to indicate a generic.
expression="execution(* com.user.service.DaoJdbc+.*(..))"
这篇关于Spring AOP 泛型类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!