SSM报错-JDBC驱动被强制取消注册

博客讲述了在SSM项目中遇到的JDBC驱动被强制注销的严重警告,原因是Spring容器被重复加载。在web.xml已配置加载Spring的情况下,ItemController.java中又使用ClassPathXmlApplicationContext加载bean.xml,引发问题。解决方法是移除控制层中重复加载bean.xml的代码,避免内存泄漏。
摘要由CSDN通过智能技术生成

严重: The web application [] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.

翻译后:

严重:Web应用程序[]注册了JDBC驱动程序[com.mysql.jdbc.Driver],但在Web应用程序停止时未能将其注销。为了防止内存泄漏,JDBC驱动程序被强制取消注册。

出错原因:
Spring 容器被重复加载。(这个原因可能仅适用于我的工程)

ItemController.java

@Controller
public class ItemController {
    ApplicationContext ac = new ClassPathXmlApplicationContext("bean.xml");
    ItemService itemService = (ItemService)ac.getBean("itemServiceImpl");

    @RequestMapping(value = "/item/itemlist.action")
    public ModelAndView itemList() {
        List<Items> itemsList = itemService.selectAllItems();
        // 获取视图对象
        ModelAndView modelAndView = new ModelAndView();
 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值