其他分享
首页 > 其他分享> > Spring框架中,普通类调用service或mapper,报空指针的解决办法

Spring框架中,普通类调用service或mapper,报空指针的解决办法

作者:互联网

package com.example.timer;

import java.util.List;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.example.dao.FileMapper;

/**
 * 定时器
 * @author limstorm
 * @create 2020-01-23 07:55:50
 */
@Component
public class TimerTask {
	
	@Autowired
	private FileMapper fileMapper;
	
	public static TimerTask timerTask;
	
	@PostConstruct
    public void init() {    
		timerTask = this;
    } 
	
	public void convertVideo() {
		List<com.example.bean.File> fileList = timerTask.fileMapper.selectFileWithAllUserVideo();
	}
}

 

limstorm 发布了22 篇原创文章 · 获赞 2 · 访问量 6443 私信 关注

标签:mapper,service,TimerTask,Spring,FileMapper,Component,timerTask,import,public
来源: https://blog.csdn.net/qq_21479345/article/details/104108058