在创建使用 Hibernate 作为 ORM 将对象保存在数据库中的服务时,我无法启动该应用程序。
我正在使用 Spring Boot 和 Hibernate。我的服务实现:
@Service
public class PropertyServiceImpl implements PropertyService{
private PropertyDAO propertyDAO;
public PropertyServiceImpl(){
System.out.println("inside propertyserviceimpl constructor");
}
@Autowired
public PropertyServiceImpl(PropertyDAO propertyDAO){
this.propertyDAO = propertyDAO;
System.out.println("inside save");
}
@Transactional
public void save(Property property) {
propertyDAO.save(property);
}
@Override
public List findAll() {
// TODO Auto-generated method stub
return null;
}
}
PropertyDAO.java
public interface PropertyDAO {
public void save(Property property);
}
PropertyDAOImpl 实现 DAO
public class PropertyDAOImpl implements PropertyDAO{
@Autowired
private SessionFactory sessionFactory;
public void save(Property property) {
Session currentSession = sessionFactory.getCurrentSession();
currentSession.saveOrUpdate(property);
}
}
当我启动 SpringBoot 应用程序时,收到以下错误消息。
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in com.flarow.flarowhomes.services.PropertyServiceImpl required a bean of type 'com.flarow.flarowhomes.dao.PropertyDAO' that could not be found.
Action:
Consider defining a bean of type 'com.flarow.flarowhomes.dao.PropertyDAO' in your configuration.
千巷猫影
慕少森
相关分类