为了账号安全,请及时绑定邮箱和手机立即绑定

使用MyBatis工具类openSession()方法,junit通过,在tomcat执行报错

使用MyBatis工具类openSession()方法,junit通过,在tomcat执行报错

慕后端2248651 2019-11-02 13:39:55
junit没问题 @Test public void testGetList(){     SqlSession sqlSession=null;     List<User> list=new ArrayList<User>();     try{         sqlSession=MyBatisUtil.openSession();         list=sqlSession.selectList("demo.selectList");         System.out.println(list);     }catch (Exception e){         e.printStackTrace();     }finally {         MyBatisUtil.closeSession(sqlSession);     }     System.out.println(list); } tomcat执行报错 public List<User> getList() {     SqlSession sqlSession=null;     List<User> list=new ArrayList<User>();     try{         sqlSession=MyBatisUtil.openSession();         list=sqlSession.selectList("demo.selectList");         System.out.println(list);     }catch (Exception e){         e.printStackTrace();     }finally {         MyBatisUtil.closeSession(sqlSession);     }     return list; } HTTP Status 500 – Internal Server Error Type 异常报告 消息 Servlet execution threw an exception 描述 服务器遇到一个意外的情况,阻止它完成请求。 Exception javax.servlet.ServletException: Servlet execution threw an exception org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) Root Cause java.lang.NoClassDefFoundError: Could not initialize class com.imooc.util.MyBatisUtil com.imooc.dao.UserDao.getList(UserDao.java:55) com.imooc.servlet.MainServlet.doGet(MainServlet.java:23) javax.servlet.http.HttpServlet.service(HttpServlet.java:634) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) Note 主要问题的全部 stack 信息可以在 server logs 里查看 Apache Tomcat/8.5.46
查看完整描述

目前暂无任何回答

  • 0 回答
  • 0 关注
  • 1598 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信