SpringBoot注入出现@org.springframework.beans.factory.annotation.Autowired(required=true)

出现以下错误:

Description:

Field photoAlbum in com.example.pet2.controller.AlbumController required a bean of type 'com.example.pet2.pojo.PhotoAlbum' 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.pet2.pojo.PhotoAlbum' in your configuration.

解决办法:

        在该实体类上添加@Component注解

@Data
@Component
public class PhotoAlbum {
    private Integer picId;

    private String picName;

    private String picture;
}

上一篇:Maven 依赖调解源码解析(四):传递依赖,第一声明者优先


下一篇:Maven 依赖调解源码解析(五):同一个文件内声明,后者覆盖前者