java.lang.NoClassDefFoundError
昨天都还好好的,今天不知道为什么就提示找不到工具类了
mappers/goods.xml
<resultMap id="rmGoods" type="com.imooc.mybatis.dto.GoodsDTO"> <!-- 设置主键字段与属性映射--> <id property="goods.goodsId" column="goods_id"></id> <!--设置非主键字段与属性映射--> <result property="goods.title" column="title"></result> <result property="goods.originaCost" column="original_cost"></result> <result property="goods.currentPrice" column="current_price"></result> <result property="goods.discount" column="discount"></result> <result property="goods.isFreeDelivery" column="is_free_delivery"></result> <result property="goods.categoryId" column="category_id"></result> <result property="category_name" column="category_name"/> <result property="test" column="test"/> </resultMap> <select id="selectGoodsDTO" resultMap="rmGoods"> SELECT g.* ,c.category_name,"1" AS test FROM t_goods g,t_category c WHERE g.category_id = c.category_id </select>
com.imooc.mybais.dto/GoodsDTO
@Test
public void testSelectGoodsDTO() throws Exception {
SqlSession session = null ;
try{
session = MyBatisUtils.openSession();
List<GoodsDTO> list = session.selectList("goods.selectGoodsDTO");
for(GoodsDTO g:list){
System.out.println(g.getGoods().getTitle());
}
}catch (Exception e){
throw e;
}finally {
MyBatisUtils.closeSession(session);
}
}这是错误提示
java.lang.NoClassDefFoundError: Could not initialize class com.imooc.mybatis.utils.MyBatisUtils at com.imooc.mybatis.MyBatisTestor.testSelectGoodsDTO(MyBatisTestor.java:155)
11
收起
正在回答
1回答
1、建议同学重新编译一下,如果是eclipse,则选择:

2、如果是idea:

或删除target文件。
3、如果还是不行,请同学贴一下你的项目目录结构截图和完整的报错信息。
4、另外,MyBatisTestor.java:155 MyBatisTestor中的第155行代码是具体哪行呢?
注意不要贴在回复里,会失去代码的格式。可以在回答里贴一下。祝学习愉快。
3. Java 数据库开发与实战应用
- 参与学习 人
- 提交作业 357 份
- 解答问题 8016 个
本阶段将带你学习MySQL数据库,JDBC接口,MyBatis框架等,带你掌握的数据的存放和管理。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星