错误:无法从 static 上下文引用非 static 字段 ‘tagLocatorMapper’
解决方式:
@Component
public class StaticTagLocatorMapper {
@Autowired
private TagLocatorMapper tagLocatorMapper;
public static TagLocatorMapper staticTagLocatorMapper;
// 项目启动时把TagLocatorMapper 交给静态的staticTagLocatorMapper
@PostConstruct
public void init() {
staticTagLocatorMapper = this.tagLocatorMapper;
}
}
使用:
StaticTagLocatorMapper.staticTagLocatorMapper.insertTagLocator()