need to invoke method 'taskExecute' declared on target class 'ShareEquallyTaskServiceImpl', but not

文章目录

  • need to invoke method 'taskExecute' declared on target class 'ShareEquallyTaskServiceImpl', but not found in any interface(s) of the exposed proxy type. Either pull the method up to an interface or switch to CGLIB proxies by enforcing proxy-target-class mode in your configuration.
        • 1、报错内容
        • 2、错误触发
        • 3、解决

need to invoke method ‘taskExecute’ declared on target class ‘ShareEquallyTaskServiceImpl’, but not found in any interface(s) of the exposed proxy type. Either pull the method up to an interface or switch to CGLIB proxies by enforcing proxy-target-class mode in your configuration.


1、报错内容

need to invoke method 'taskExecute' declared on target class 'ShareEquallyTaskServiceImpl', 
but not found in any interface(s) of the exposed proxy type. Either pull the method up to 
an interface or switch to CGLIB proxies by enforcing proxy-target-class mode in your configuration.

2、错误触发

在一个springboot 应用中,在一个接口的实现类里面写了方法,这个方法是一个异步的定时任务,这个定时任务需要去处理接口方法的逻辑,但是又不希望这个方法被接口暴露出去。所以在接口里面没有定义这个方法,然后spring 在启动的时候说,在公开的接口方法中找不到这个方法,所以创建bean 失败

  @Scheduled(cron = "0 0 5 1/1 * ? ")
  @Async
  public void shareEquallyTaskExecute() {}

3、解决

在接口中定义这个方法,然后实现类里面实现即可

  @Override
  @Scheduled(cron = "0 0 5 1/1 * ? ")
  @Async
  public void shareEquallyTaskExecute() {}

你可能感兴趣的:(#,异常(Exception))