SpringBoot-(十七)SpringBoot启动报错代理问题解决办法

本文最后更新于:April 29, 2022 am

SpringBoot框架中有两个非常重要的策略:开箱即用和约定优于配置。其设计目的是用来简化新Spring应用的初始搭建以及开发过程。该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置。

目录

报错

1
2
3
4
5
6
7
8
9
10
11
12
13
***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'RecordServiceImpl' could not be injected as a 'com.tothefor.service.impl.RecordServiceImpl' because it is a JDK dynamic proxy that implements:
com.tothefor.service.RecordService


Action:

Consider injecting the bean as one of its interfaces or forcing the use of CGLib-based proxies by setting proxyTargetClass=true on @EnableAsync and/or @EnableCaching.

解决办法

方法一(已测试)

在启动类上加注解: @EnableTransactionManagement(proxyTargetClass = true) 即可。

1
2
3
4
5
6
7
8
9
@EnableTransactionManagement(proxyTargetClass = true)
@SpringBootApplication
public class ClgcJavaApplication {

public static void main(String[] args) {
SpringApplication.run(ClgcJavaApplication.class, args);
}

}

方法二

使用 @Transactional,开启@Transactional 注解支持。未试过,网上有这种解决办法,所及记录在此。