zoukankan      html  css  js  c++  java
  • Junit测试

    第一种:

    @ContextConfiguration(locations = {"classpath*:/spring-core.xml"})
    public class UserMapperTest extends AbstractJUnit4SpringContextTests {
    
        @Resource
        private UserMapper userMapper;
    
        @Test
        public void testQueryAllUser () {
            User user = userMapper.queryById("1");
    
            System.out.println(user.getName());
        }
    }

    第二种:

    public class UserMapperTest2 {
    
        private UserMapper userMapper;
        
        @Before
        public void init(){
            ApplicationContext ctx = new FileSystemXmlApplicationContext("classpath*:/spring/applicationContext.xml");  
            userMapper = (UserMapper)ctx.getBean("userMapper");
        }
    
        public UserMapper getUserMapper() {
            return userMapper;
        }
    
        public void setUserMapper(UserMapper userMapper) {
            this.userMapper = userMapper;
        }
        
    }

    UserMapper需要加注解:

    /**
     * 用户信息数据持久化操作接口
     */
    @Repository
    public interface UserMapper extends BaseMapper<User>

    IT技术和行业交流群 417691667

  • 相关阅读:
    Roles in graphs
    COMMUNITY DETECTION
    jquery官方API
    react打包后引入
    pc网站相互跳转
    动画点击事件
    导入组件
    纯css制作loading效果
    canvas时钟
    canvas实现动画 地球绕太阳公转 月球绕地球公转
  • 原文地址:https://www.cnblogs.com/sun-rain/p/5766782.html
Copyright © 2011-2022 走看看