Exception in thread “main” org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘petStore’ defined in class path resource [service.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.samples.jpetstore.services.PetStoreServiceImpl]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.samples.jpetstore.services.PetStoreServiceImpl.()
解决方法:
这个错误的意思是没有定义默认的构造方法。什么是默认的构造方法呢,就是无参的构造方法,当定义了有参的构造方法时,也要同时定义无参的构造方法。如果没有写构造方法是可以自动添加默认的(也就是无参的构造方法)。
例如:
public PetStoreServiceImpl() {
super();//super()可以不加
}
```