ServletContext context = request.getSession().getServletContext();
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(context);
DataSource dbSource = (DataSource) wac.getBean("dataSource"); //配置文件里的beanid
Connection con = null;
try {
con = dbSource.getConnection();
} catch (SQLException e) {
e.printStackTrace();
}

相关文章:

  • 2022-12-23
  • 2021-08-13
  • 2021-12-15
  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
  • 2021-03-31
  • 2021-06-12
猜你喜欢
  • 2022-12-23
  • 2022-01-03
  • 2021-06-25
  • 2021-12-18
  • 2022-12-23
  • 2021-07-28
相关资源
相似解决方案