commandlineRunner
@SpringBootApplication
asf4j
public class DataSourceDemoApplication implements CommandLineRunner (@Autowiredprivate DataSource dataSource;
public static void main(String[] args) {
SpringApplication.run(DataSourceDemoApplication.class,args);
@Override
public void run(String... args) throws Exception {log.info(dataSource.toString());
Connection conn = dataSource.getConnection();log.info(conn.toString());conn.close();
摘抄自网络,便于检索查找。