小编beg*_*992的帖子

上下文初始化期间遇到异常 - 取消刷新尝试:org.springframework.beans.factory.UnsatisfiedDependencyException

我正在开发一个 Spring Boot 应用程序。尝试了很多办法都没有解决,请帮忙:

控制台: org.springframework.beans.factory.UnsatisfiedDependencyException:创建名称为“doctorController”的bean时出错:通过字段“doctorService”表达的依赖关系不满足;嵌套异常是 org.springframework.beans.factory.UnsatisfiedDependencyException:创建名称为“doctorService”的 bean 时出错:通过字段“doctorRepo”表达的依赖关系不满足;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建名称为“doctorRepository”的 bean 时出错:调用 init 方法失败;嵌套异常是 org.springframework.data.mapping.PropertyReferenceException:找不到类型 Doctor 的属性 id!

引起:org.springframework.beans.factory.UnsatisfiedDependencyException:创建名称为“doctorService”的bean时出错:通过字段“doctorRepo”表达的依赖关系不满足;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建名称为“doctorRepository”的 bean 时出错:调用 init 方法失败;嵌套异常是 org.springframework.data.mapping.PropertyReferenceException:找不到类型 Doctor 的属性 id!

控制器:

@RestController
public class DoctorController {

    @Autowired
    private DoctorService doctorService;

    @RequestMapping("/hms/doctor")
    public List<Doctor> getAllDoctor()
    {
        return doctorService.getAllDoctor();
    }

    @RequestMapping(method=RequestMethod.POST,value="hms/doctor")
    public void addDoctor(@RequestBody Doctor doctor)
    {
        doctorService.addDoctor(doctor);

    }
}
Run Code Online (Sandbox Code Playgroud)

服务等级:

@Service
public class DoctorService {

    Logger logger= LoggerFactory.getLogger(DoctorService.class);

    @Autowired
    private DoctorRepository doctorRepo;

    public List<Doctor> getAllDoctor(){

        logger.error("error happened");
        logger.trace(" Error !!!");
        List<Doctor> doctor= …
Run Code Online (Sandbox Code Playgroud)

java spring-boot spring-data-cassandra

7
推荐指数
1
解决办法
6万
查看次数

标签 统计

java ×1

spring-boot ×1

spring-data-cassandra ×1