2

有没有人设法让 Jersey 与 AspectJ 一起工作(从春天开始)?

在我的示例中,我在 java/groovy 中有一个球衣类:

@Component
@Path("/resource")
class Resource{

    @Autowired
    ResourceAccess resourceAccess 

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public String getResource(@QueryParam("name") String name){
        def res= resourceAccess.getResource(name)
        return res
    }

...
}

它工作得很好,resourceAccess 由 Spring 注入, /resource?name=test 返回我名为 test 的资源

但是当我想在游戏中引入 AspectJ (AOP) 时,resourceAccess 对象不再被注入,我的 Advice 甚至没有被执行。

我在 applicationContext.xml 中添加并创建了我的方面:

@Aspect
@Component
public class MyAspect{
    static final Logger logger = LoggerFactory.getLogger(MyAspect.class);

    @Before("execution(* com.test.Resource.getResource(..))")
    public void logBefore(JoinPoint joinPoint) {
        logger.debug("logBefore() is running!");
    }
}

备注:如果我将建议中的切入点更改为针对其他目标,它会再次正常工作。

有人能在这个问题上帮助我吗?

4

0 回答 0