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 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)