I know this is very often asked , but I cannot find a working solution :
This is my AbstractDAO :
public interface AbstractDao
{
public T
You're solving the wrong problem. Proxied beans are not meant to be casted to the original classes, one way or the other. That would break the whole point of dependency injection. After all: when you specify a dependency as an interface you are requesting a bean that fulfills a contract, but not the implementation details. Casting it to the original bean class breaks this loose coupling.
You are saying the additional methods are backed up by an interface you call OtherInterface
, so why not use that instead? After all, the proxy will implement all the target class' interfaces, not only the injected one.
@Test
public void testAdditionalMethod()
{
OtherInterface oi = (OtherInterface) dao;
System.out.println(oi.additionalMethod(...));
}
Basically you have these options (sorted from clean to dirty):
OtherInterface
and PersonDao
and
let your bean implement that
metainterfaceyes spring always creates proxy classes and thats how it actually discovered non intrusive weaving and aop by xml config... try googling for that error in spring documentation there shud be rules to follow and work arounds.