Spirng注解和dbutils集成
2.DBUtilsTemplate
public static ClassPathXmlApplicationContext context = null;public static ClassPathXmlApplicationContext getContextInstance() {if (context == null) {start();}if (!context.isRunning()) {CopyOfApp.context.refresh();context.registerShutdownHook();}return context;}private static void start() {context = new ClassPathXmlApplicationContext("classpath:spring-source.xml");context.registerShutdownHook();}public static void main(String[] args) throws Exception {App.start();App.context.refresh();DBUtilsTemplate dbUtilsTemplate = CopyOfApp.context.getBean("dbUtilsTemplate", DBUtilsTemplate.class);String sql = "select count(1) from admin";List<Map<String, Object>> list = dbUtilsTemplate.find(sql);System.out.println(list + "--"); }
?
?