一路繁花似锦绣前程
失败的越多,成功才越有价值

导航

 

一、整合测试

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <scope>test</scope>
</dependency>
@Before
public void test01(){
    System.out.println("aaaaaa");
}
@Test
public void test02(){
    System.out.println("bbbbbb");
}
@After
public void test03(){
    System.out.println("cccccc");
}
@RunWith(SpringRunner.class)
@SpringBootTest(classes = MyApplication.class)
public class MyTestDao {
    @Autowired
    private PersonMapper personMapper;

    @Test
    public void test01() {
        PersonExample example = new PersonExample();
        example.createCriteria().andNameLike("%string%");
        example.or(example.createCriteria().andAgeEqualTo(27));
        List<Person> list = personMapper.selectByExample(example);
        System.out.println(list);
    }

    @Test
    public void test02() {
        // service
        PersonExample example = new PersonExample();
        PageHelper.startPage(1, 10);
        List<Person> list = personMapper.selectByExample(example);
        // controller
        PageInfo<Person> info = new PageInfo<>(list);
        System.out.println(info);
    }
}

 

二、整合log4j

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-logging</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-log4j</artifactId>
    <version>1.3.8.RELEASE</version>
</dependency>

  创建log4j.properties配置文件

log4j.logger.com.wuxi.dao=debug,console

log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern= [%d{HH:mm:ss}] %m%n

 

posted on 2020-03-27 22:03  一路繁花似锦绣前程  阅读(600)  评论(0编辑  收藏  举报