【四:Spring整合Junit】

编程入门 行业动态 更新时间:2024-10-18 22:36:50

【四:<a href=https://www.elefans.com/category/jswz/34/1769862.html style=Spring整合Junit】"/>

【四:Spring整合Junit】

目录

        • 相同点
        • 不同点
          • 1、导入依赖增加
          • 2、编写的位置不同。。路径一定要与实现类一致

相同点

前面都一样和Spring整合mybatis(基于注解形式)一样
Spring整合Mybatis

不同点

1、导入依赖增加
        <!-- 单元测试 --><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version><scope>test</scope></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-test</artifactId><version>5.2.10.RELEASE</version></dependency>

2、编写的位置不同。。路径一定要与实现类一致

package com.xiong.service;import com.xiong.config.SpringConfig;
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;@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = SpringConfig.class)
public class AccountServiceTest {@Autowiredprivate AccountService accountService;@Testpublic  void  testFindById(){System.out.println(accountService.findById(1));}
}

更多推荐

【四:Spring整合Junit】

本文发布于:2023-12-07 10:40:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1671024.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Spring   Junit

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!