使用Spring报错:No default constructor found;

时间:2023-03-09 05:15:31
使用Spring报错:No default constructor found;

Exception in thread "main" org.springframework.beans.factory.BeanCreationException:

Error creating bean with name 'CustomerBean' defined in class path resource [Spring-Customer.xml]:

Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.yiibai.common.Customer]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.yiibai.common.Customer.()

使用Spring注解时要提空默认的构造函数

提供默认的构造函数就好了。