package com.xjrsoft.xjrsoftboot;

import com.alibaba.fastjson.JSON;
import com.xjrsoft.XjrSoftApplication;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.junit4.SpringRunner;

import javax.sql.DataSource;
import java.util.List;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = XjrSoftApplication.class)
public class DataSourceTest {
    @Test
    public void DataSourceTest() {
        // 获取配置的数据源
//        DataSource dataSource = applicationContext.getBean(DataSource.class);
//        // 查看配置数据源信息
//        System.out.println(dataSource);
//        System.out.println(dataSource.getClass().getName());
//        System.out.println(dataSourceProperties);
//        //执行SQL,输出查到的数据
//        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
//        List<?> resultList = jdbcTemplate.queryForList("select * from xjr_user");
//        System.out.println("===>>>>>>>>>>>" + JSON.toJSONString(resultList));
    }
}
