项目启动后报错:
Description:
Field gradeService in com.example.zhxy.controller.GradeController required a bean of type 'com.example.zhxy.service.GradeService' 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 'com.example.zhxy.service.GradeService' in your configuration.
说明:
@Autowired 一般用来自动装配,但是需要对象注册成bean(有对应实例)。。
可以装配的举例:
1.带有@service的类
会自动注入,注册成bean
2. 带有@Component的类
会自动注入,注册成bean
3.带有@Configuration的类
会自动注入,注册成bean