开发者社区 问答 正文

在spring中使用ActiveRecordPlugin,用start启动后,是否需要调用stop方法关闭

我在spring中使用ActiveRecordPlugin,用start启动后,是否需要用stop方法关闭。

public class ActiveRecordConfig implements InitializingBean {
    @Autowired
    private DataSource dataSource;
    @Autowired
    private DataSource dataSourceYHT;
 
    public void afterPropertiesSet() throws Exception {
        ActiveRecordPlugin arp = new ActiveRecordPlugin("def", dataSource);
        arp.setDialect(new MysqlDialect());
        arp.setShowSql(true);
        _MappingKit.mapping(arp);
 
        ActiveRecordPlugin yhtArp = new ActiveRecordPlugin("yht", dataSourceYHT);
        yhtArp.setDialect(new MysqlDialect());
        yhtArp.setShowSql(true);
        _yhtMappingKit.mapping(yhtArp);
 
        arp.start();
        yhtArp.start();
    }
}

在spring启动后加载ActiveRecordPlugin,并调用它的start方法。启动后,资源是否需要在哪里调用它的stop方法???

展开
收起
a123456678 2016-03-19 09:43:16 2076 分享 版权
1 条回答
写回答
取消 提交回答
  • stop() 方法用于回收资源,如果是 JVM 关闭退出性质的不调用 stop() 也可以

    2019-07-17 19:07:19
    赞同 展开评论