栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

spring里面有bean,但是@Autowrite注入不进去

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

spring里面有bean,但是@Autowrite注入不进去

caontroller层

@RequestMapping("/video")
@RestController
public class VedioController {
//    @Resource(name= "videoServiceImpl")
    @Autowired
    private VideoService videoService;

    @RequestMapping("/list")
    @LogAnnotation(module = "视频",operation = "获取视频列表")
    private Result getVedioList(@RequestBody QueryParams queryParams){
        DataVo vedioList = videoService.getVedioList(queryParams);
        return Result.success(vedioList);
    }

    @RequestMapping("/add")
    @LogAnnotation(module = "视频",operation = "获取视频列表")
    private Result addVeedio(@RequestBody VideoParams videoParams){
        Result result = videoService.addVedio(videoParams);
        return Result.success(result);
    }
    @RequestMapping("/del")
    @LogAnnotation(module = "视频",operation = "获取视频列表")
    private Result delVedio(@RequestParam Integer id){
        videoService.delVedio(id);
        return Result.success(null);
    }
    @RequestMapping("/edit")
    @LogAnnotation(module = "视频",operation = "获取视频列表")
    private Result editVedio(@RequestBody VideoParams videoParams){
        return Result.success(videoService.editVedio(videoParams));
    }

}

service层

@Service
@Transactional
public class VideoServiceImpl implements VideoService {

    @Autowired
    private VideoMapper videoMapper;
    @Autowired
    private TeacherService teacherService;
    @Autowired
    private DataVo dataVo;

    @Override
    public DataVo getVedioList(QueryParams queryParams) {
        Page

这个是打印spring里面的bean名称,红框中的bean就是注入不进去的bean

最后问题发现是因为controller中的方法都是private,然后就改成public就没有问题了
最后把打印bean的代码

 @Bean
    public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
        return args -> {

            System.out.println("Let's inspect the beans provided by Spring Boot:");

            String[] beanNames = ctx.getBeanDefinitionNames();
            Arrays.sort(beanNames);
            for (String beanName : beanNames) {
                System.out.println(beanName);
            }

        };
    }
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/782020.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号