gpt4 book ai didi

Spring 应用程序有 Cglib2AopProxy 警告

转载 作者:IT老高 更新时间:2023-10-28 13:52:47 26 4
gpt4 key购买 nike

在启动我的应用程序时,我收到了许多类似于 o.s.aop.framework.Cglib2AopProxy 'Unable to proxy method [public final void org.springframework.jdbc.core.support.JdbcDaoSupport.setDataSource(javax.sql.DataSource)] because it is final: All calls to this method via a proxy will be routed directly to the proxy.' 的警告大约十几个功能。

现在我完全明白基于代理的方面不能应用于 final方法。然而,我并没有(至少是故意的)试图将任何方面编织到 JdbcDaoSupport 中。 .我怀疑它来自 <tx:annotation-driven /> .我可以做些什么来消除这些警告,或者更好的是,将这些类从方面编织中排除?

最佳答案

这很可能是由 @Transactional 注释引起的,Spring 将您的 DAO 包装在代理中以添加事务行为。

我建议让你的 DAO 实现一个接口(interface)(为你的 DAO 创建和使用一个接口(interface)),这将允许 Spring 使用 JDK 动态代理,而不必使用 CGLib。 p>

Using CGLIB has a limitation that methods marked as final in target class can’t be advised as final methods can’t be overridden (CGLIB creates a subclass of target class at runtime) but this limitation disappears in case of using JDK dynamic proxies.

Reference

关于Spring 应用程序有 Cglib2AopProxy 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12690349/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com