Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 错误::";创建名为“的bean”时出错;春天_Java_Spring_Spring Mvc_Spring Data Jpa_Spring Jdbc - Fatal编程技术网

Java 错误::";创建名为“的bean”时出错;春天

Java 错误::";创建名为“的bean”时出错;春天,java,spring,spring-mvc,spring-data-jpa,spring-jdbc,Java,Spring,Spring Mvc,Spring Data Jpa,Spring Jdbc,**野生飞行服务器日志::** org.springframework.beans.factory.UnsatifiedDependencyException:创建名为“customerController”的bean时出错:通过字段“customerService”表示的未满足的依赖关系; 原因:java.lang.RuntimeException:org.springframework.beans.factory.unsatifiedDependencyException:创建名为“cust

**野生飞行服务器日志::** org.springframework.beans.factory.UnsatifiedDependencyException:创建名为“customerController”的bean时出错:通过字段“customerService”表示的未满足的依赖关系; 原因:java.lang.RuntimeException:org.springframework.beans.factory.unsatifiedDependencyException:创建名为“customerController”的bean时出错:通过字段“customerService”表示的未满足的依赖关系;嵌套异常为org.springframework.beans.factory.NoSuchBeanDefinitionException: Spring服务实现代码::

    package com.edifixio.training.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.edifixio.training.dao.CustomerDAO;
import com.edifixio.training.entity.Customer;

@Service
public class CustomerServiceImpl {

    @Autowired
    private CustomerDAO customerDAO;


    @Transactional
    public List < Customer > getCustomers() {
        return customerDAO.getCustomers();
    }


    @Transactional
    public void saveCustomer(Customer theCustomer) {
        customerDAO.saveCustomer(theCustomer);
    }


    @Transactional
    public Customer getCustomer(int theId) {
        return customerDAO.getCustomer(theId);
    }


    @Transactional
    public void deleteCustomer(int theId) {
        customerDAO.deleteCustomer(theId);
    }

}
包com.edifixio.training.service;
导入java.util.List;
导入org.springframework.beans.factory.annotation.Autowired;
导入org.springframework.stereotype.Service;
导入org.springframework.transaction.annotation.Transactional;
导入com.edifixio.training.dao.CustomerDAO;
导入com.edifixio.training.entity.Customer;
@服务
公共类CustomerServiceImpl{
@自动连线
私人客户道客户道;
@交易的
公共列表getCustomers(){
返回customerDAO.getCustomers();
}
@交易的
公共作废保存客户(客户-客户){
客户道。保存客户(客户);
}
@交易的
公共客户getCustomer(inttheid){
返回customerDAO.getCustomer(theId);
}
@交易的
公共客户(int theId){
customerDAO.deleteCustomer(theId);
}
}

错误的相关部分是:

没有类型为的限定bean “com.edifixio.training.service.CustomerService”可用:预计在 至少1个符合autowire候选资格的bean

您的服务
CustomerServiceImpl
缺少
implements
部分,并且永远不会被视为
CustomerService
bean

只需将类声明为:

@Service
public class CustomerServiceImpl implements CustomerService

向服务提供代码很好,但是如果没有注入代码,可能很难帮助您。