@RequestMapping("")
@MapperScan("com.jatham.cloud.platform.mapper")
@Component
public class H2Client{
//注入mappper
@Autowired
private UserMapper userMapper;
@Autowired
private DataNodeMapper dataNodeMapper;
public static H2Client h2Client;
@PostConstruct
public voidinit(){
h2Client= this;
h2Client.dataNodeMapper= this.dataNodeMapper;}
需要注解
@Component
@Autowired 自动装配
@PostConstruct
被@PostConstruct修饰的方法会在服务器加载Servlet的时候运行,并且只会被服务器调用一次,类似于Serclet的inti()方法。被@PostConstruct修饰的方法会在构造函数之后,init()方法之前运行。