• Spring集成JUnit测试


    1.程序中有Junit环境
    2.导入一个jar包.spring与junit整合jar包
      spring-test-3.2.0.RELEASE.jar
    3.测试代码

    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration(locations="classpath:applicationContext.xml")
    public class SpringTest {
      @Autowired
      private UserService userService;
    
      @Test
      public void demo1(){
        userService.sayHello();
      }
    }
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:p="http://www.springframework.org/schema/p"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="
                http://www.springframework.org/schema/beans 
                http://www.springframework.org/schema/beans/spring-beans.xsd">
        <bean id="userService" class="cn.yzu.service.UserService"></bean>
    </beans>
  • 相关阅读:
    mysql问题: alter导致速度慢
    MySQL的mysql_insert_id和LAST_INSERT_ID
    linux动态链接库---一篇讲尽
    jsoncpp第二篇------API
    SVN第二篇-----命令集合
    svn第一篇----入门指南
    数据结构之堆
    SZU4
    SZU1
    SZU2
  • 原文地址:https://www.cnblogs.com/fengmingyue/p/6202970.html
Copyright © 2020-2023  润新知