idea springboot 启动问题

在启动springboot中遇到了这样的问题
2022-09-21 02:07:19.012 INFO 2200 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2022-09-21 02:07:19.019 INFO 2200 --- [ main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-09-21 02:07:19.035 ERROR 2200 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :


APPLICATION FAILED TO START


Description:

Field cate in cn.edu.neu.hellospringboot.controller.HelloController required a bean of type 'cn.edu.neu.hellospringboot.model.Categray' that could not be found.

The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)

Action:

Consider defining a bean of type 'cn.edu.neu.hellospringboot.model.Categray' in your configuration.

Process finished with exit code 1

img

img

启动代码截图如下:
package cn.edu.neu.hellospringboot.controller;

import cn.edu.neu.hellospringboot.config.MyService;
import cn.edu.neu.hellospringboot.model.Categray;
import cn.edu.neu.hellospringboot.model.Person;
import cn.edu.neu.hellospringboot.model.User;
import cn.edu.neu.hellospringboot.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
@Autowired
public User user;
@Autowired
public Categray cate;

@Autowired
public Person person;
@Autowired
public HelloService service;

@Autowired
public MyService myService;

@RequestMapping("/")
public  String hello(){
    String result=service.getData();

    myService.testMyservice();

    System.out.println(user);
   // System.out.println(cate);
    System.out.println(person);
    return result+user.getUser_name();

// return "Hello SpringBoot!";
}
}

img


求解答!

categray这个类是Javabean吧,你肯定不能用autowired注解注入,因为spring上下文压根就没有这个bean,所以报错了,你看看报错,很明确的。
对于javabean,通常是new这个对象

这个报错是告诉你Categray 这个对象没有给spring 容器管理。 排查一下你的Categray 这个类有没有交给spring 管理