qq_36325121
爱折腾的Albert
采纳率0%
2018-05-14 10:04 阅读 501

ssm整合Junit4 报 绑定异常

5

这个测试我之前是可以用的。然后我重新装系统了。重新git下来就是这样了。

package com.komlin.modular.mapper;
import Model.ClassArrangeData;
import com.komlin.component.Junit.JUnit4ClassRunner;
import com.komlin.component.utils.PoiUtil;
import com.komlin.component.utils.UUIDUtils;
import com.komlin.modular.education.mapper.*;
import com.komlin.modular.education.model.ClassInfo;
import com.komlin.modular.education.model.Course;
import com.komlin.modular.education.model.StudentScore;
import com.komlin.modular.education.pojo.dto.*;
import com.komlin.modular.education.pojo.vo.response.StudentCouserArrangeResponse;
import com.komlin.modular.system.mapper.MenuMapper;
import com.komlin.modular.system.mapper.RoleMenuMapper;
import com.komlin.modular.system.mapper.UserInfoMapper;
import com.komlin.modular.system.model.Menu;
import com.komlin.modular.system.model.RoleMenu;
import com.komlin.modular.system.model.UserInfo;
import com.komlin.modular.system.DTO.SelectProfessionInfoByUserIdDTO;
import net.sf.json.JSONArray;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.*;

/**

  • @author huzhengxing
  • @description:
  • @date 2017/11/6 15:46
    /
    @RunWith(JUnit4ClassRunner.class)
    @ContextConfiguration(locations = "classpath:spring/applicationContext-
    .xml")
    public class EducationMapperTest {

    private Logger logger = Logger.getLogger(EducationMapperTest.class);

    @Autowired
    private UserInfoMapper userInfoMapper;

    @Autowired
    private ClassInfoMapper classInfoMapper;

    @Autowired
    private CourseArrangeMapper courseArrangeMapper;

    @Autowired
    private TutorTeacherMapper tutorTeacherMapper;

    @Autowired
    private ProfessionArrangeMapper professionArrangeMapper;

    @Autowired
    private StudentScoreMapper studentScoreMapper;

    @Autowired
    private CourseMapper courseMapper;

    @Autowired
    private MenuMapper menuMapper;

    @Autowired
    private RoleMenuMapper roleMenuMapper;

    @Test
    public void insertRoleMenu() {
    List

    menus = menuMapper.selectMenuList();
    for (Menu menu : menus) {
    RoleMenu record = new RoleMenu();
    record.setRmId(UUIDUtils.getUniquekey());
    record.setRmRId(4);
    record.setRmMId(menu.getMenuId());
    roleMenuMapper.insertSelective(record);
    }
    }

    @Test
    public void listCourseArrange() {
    List courseArrangeDTOS = courseArrangeMapper.listCourseArrange(null, null, null, null, null, null);
    System.out.println(courseArrangeDTOS);
    }

    @Test
    public void listStudentInfo() {
    System.out.println(JSONArray.fromObject(userInfoMapper.listStudentInfo()));
    }
    }

异常

ocking Pass-Through Statistic: LOCAL_DISK_SIZE_BYTES>
2018-05-14 17:39:16,952 DEBUG [net.sf.ehcache.statistics.extended.ExtendedStatisticsImpl] -
2018-05-14 17:39:16,952 DEBUG [net.sf.ehcache.statistics.extended.ExtendedStatisticsImpl] -
2018-05-14 17:39:16,952 DEBUG [net.sf.ehcache.statistics.extended.ExtendedStatipl] -
2018-05-14 17:39:16,953 DEBUG [net.sf.ehcache.statistics.extended.ExtendedStatisticsImpl] -
2018-05-14 17:39:16,995 DEBUG [net.sf.ehcache.statistics.extended.ExtendedStati9:16,997 DEBUG [net.sf.ehcache.statistics.extended.ExtendedStati

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.komlin.modular.education.mapper.StudentScoreMapper.listStudentInfo

at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:189)
at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:43)
at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:58)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:51)
at com.sun.proxy.$Proxy31.listStudentInfo(Unknown Source)
at com.komlin.modular.mapper.EducationMapperTest.insertStudentScore(EducationMapperTest.java:273)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:254)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:193)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Disconnected from the target VM, address: '127.0.0.1:39803', transport: 'socket'

Process finished with exit code 255

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

5条回答 默认 最新

  • qq_35921762 奶儿 2018-05-14 10:08

    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

    点赞 评论 复制链接分享
  • QQ00821 终于等到伱 2018-05-14 10:24

    mapper.xml文件中的方法名和dao类中的方法名不一致

    点赞 评论 复制链接分享
  • xyt3198 xyt3198 2018-05-14 10:35

    直接原因就是mybatis找不到listStudentInfo这个方法所映射的sql,如果你上面的listCourseArrange方法执行成功,但是下面的方法执行错误,应该是mybatis的xml文件有问题,请检查userInfoMapper所对应的xml文件,如果两个方法都没有执行成功,那么请检查applicationContext.xml中mybatis在spring中的配置是否正确,比如扫描mapper的xml的路径是否正确

    点赞 评论 复制链接分享
  • ilifetree hi-face 2018-05-15 00:34
  • ilifetree hi-face 2018-05-15 08:04

相关推荐