idea 开启单元测试

正经创建一个maven项目 然后ssm框架放好

遵循网上log4j导入方法 导入

然后 新建directory  右键mark directory as  选test source boot 变成绿色

然后新建一个class

import com.iflytek.pojo.User;
import com.iflytek.service.UserService;
import org.apache.log4j.Logger;
import org.joda.time.DateTime;
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 javax.annotation.Resource;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:spring.xml"})
public class test {
    private static Logger logger = Logger.getLogger(test.class);
    @Resource
    private UserService userService;

    @Test
    public void countTest() {
        //        System.out.print(1312);
        String format = "yyyy-MM-dd";
        String start = "2018-2-14";
        DateTime time1 = new DateTime(start);
        DateTime time2 = new DateTime();
        logger.info(time2.dayOfWeek().withMaximumValue().plusDays(1));
    }

}

其中打印到控制台就用logger.info指令即可

下面这个()中填写当前类

contextconfiguration 的地址连到项目文件夹中配置好的spring.xml  就是用来整合spring.xml 和mybatis.xml的配置文件

private static Logger logger = Logger.getLogger(test.class);


配置文件方法有很多,网上有很多方法 但最好用自己的固定模板 这样bean的规范会便于使用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值