Closed klaus-cicd closed 4 months ago
你需要百度AOP常见失效原因, 提问也不贴工具类啥样,注解在了哪。
你需要百度AOP常见失效原因, 提问也不贴工具类啥样,注解在了哪。
@Slf4j @DS(TDengineUtil.DS_TDENGINE) public class TDengineUtil { public static final String DS_TDENGINE = "tdengine"; @Getter private NamedParameterJdbcTemplate namedParameterJdbcTemplate; private static NamedParameterJdbcTemplate STATIC_NAMED_PARAMETER_JDBC_TEMPLATE; private static JdbcTemplateUtil STATIC_JDBC_TEMPLATE_UTIL;
private final JdbcTemplateUtil jdbcTemplateUtil;
private final SpringContextHolder springContextHolder;
public TDengineUtil(NamedParameterJdbcTemplate namedParameterJdbcTemplate, SpringContextHolder springContextHolder, JdbcTemplateUtil jdbcTemplateUtil) {
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
this.springContextHolder = springContextHolder;
this.jdbcTemplateUtil = jdbcTemplateUtil;
STATIC_NAMED_PARAMETER_JDBC_TEMPLATE = namedParameterJdbcTemplate;
STATIC_JDBC_TEMPLATE_UTIL = jdbcTemplateUtil;
}
public static int insertUsing(Object object) {
return insertUsing(object, new DefaultDynamicNameStrategy());
}
... }
你需要百度AOP常见失效原因,谁教的AOP可以这么用
Please fill it out carefully, or it will be closed. 请认真填写,不然会直接关闭。
Enviroment
JDK Version(required): 1.8
SpringBoot Version(required): 2.4.1
dynamic-datasource-spring-boot-starter Version(required): 4.2.0
druid Version(optional): 1.2.16
Describe what happened
DynamicDataSourceContextHolder.peek()
的结果为null,导致namedParameterJdbcTemplate对象获取到的是mysql的数据源,进而导致结果异常Expected Result:
AOP正常生效,进入DynamicDataSourceAnnotationInterceptor
Actual Result: AOP失效,未执行DynamicDataSourceAnnotationInterceptor#invoke
If there is an exception,or aop invalid,please attach the exception trace:
Steps to reproduce
Step 1
Step 2
Step 3