<dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>${junit.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-test</artifactId>
                <version>${spring.version}</version>
                <scope>test</scope>
            </dependency>

2、重新install 一下父工程,否则在执行run方法时会报错

3、创建test类,在类的头部添加注解即可

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:spring/applicationContext-*.xml")
public class UserTest {
    @Autowired 
    private UserService userService;
    @Test
    public void test() {
        TUser user = new TUser();
        user.setAge(0);
        int addUser = userService.addUser(user);
        System.out.println(addUser);
    }

}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-22
  • 2021-08-14
  • 2021-09-16
  • 2022-02-05
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-22
  • 2021-09-03
  • 2021-10-06
  • 2021-10-25
  • 2021-12-31
  • 2021-12-04
  • 2022-12-23
相关资源
相似解决方案