springboot项目在普通类中调用maper或者service接口
Posted H-Desiger
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了springboot项目在普通类中调用maper或者service接口相关的知识,希望对你有一定的参考价值。
package com.zch.tools; import com.zch.bean.TableBean; import com.zch.bean.TranslateBean; import com.zch.mapper.FillerMapper; import org.apache.poi.hwpf.HWPFDocument; import org.apache.poi.hwpf.usermodel.*; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFTable; import org.apache.poi.xwpf.usermodel.XWPFTableCell; import org.apache.poi.xwpf.usermodel.XWPFTableRow; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; import java.io.FileInputStream; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * @Author:zhaochunhui; * @Description: * @Date:Create in 10:24 2019/12/29 */ //1 @Component public class Judge { //2 @Autowired private FillerMapper fillerMapper; public static Judge judge; //3 @PostConstruct public void init(){ judge = this ; //4 judge.fillerMapper = this.fillerMapper; } //你要封装的方法 public void judgeProductStatus(){ //5 judge.fillerMapper.getEngCharByChainChar(); } }
以上是关于springboot项目在普通类中调用maper或者service接口的主要内容,如果未能解决你的问题,请参考以下文章
SpringBoot学习-SpringBoot中其他普通类调用Spring管理的Servicedao等bean
SpringBoot 普通类中获取Bean对象(dao、service...)