import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidPooledConnection;
import com.controller.UserController;
import com.service.UserService;
import com.service.impl.UserServiceImpl;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {
    public static void main(String[] args) throws Exception {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("context.xml");
        BeanFactory beanFactory = (BeanFactory) applicationContext;
//        ApplicationContext applicationContext = new FileSystemXmlApplicationContext("C:\\java\\renren\\spring_demo\\src\\main\\resources\\context.xml");
        Object userController = beanFactory.getBean(UserController.class);
        UserService bean = applicationContext.getBean(UserServiceImpl.class);
//        DruidDataSource dataSource = (DruidDataSource) beanFactory.getBean("dataSource");
        DruidDataSource dataSource = beanFactory.getBean(DruidDataSource.class);
        //       JdbcData bean1 = beanFactory.getBean(JdbcData.class);
        DruidPooledConnection connection = dataSource.getConnection();
        connection.close();
        // userService1 在 xml文件中定义
       //  MqService mqService = applicationContext.getBean(MqServiceImpl.class);
        // mqService.pushRabbitMessage();
//         mqService.listenRabbitQueue();
        Object testStringBean = beanFactory.getBean("testStringBean");
    }

}
