weixin_57377772 2022-09-21 02:15 采纳率: 56.3%
浏览 81
已结题

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


求解答!

  • 写回答

3条回答 默认 最新

  • 燕少༒江湖 2022-09-21 07:45
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 9月29日
  • 已采纳回答 9月21日
  • 创建了问题 9月21日

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算