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() {}