mybatis.mapper-locations=classpath:mappers/**/*.xml
mybatis:
mapper-locations: classpath:mappers/**/*.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="">
</mapper>
package com.example.demo;
import com.example.demo.domain.TempVO;
import com.example.demo.mapper.TempMapper;
import org.junit.jupiter.api.Test;
import org.mybatis.spring.boot.test.autoconfigure.MybatisTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
@AutoConfigureTestDatabase(replace= AutoConfigureTestDatabase.Replace.NONE)
@MybatisTest
public class MyBatisTests {
@Autowired(required = false)
private TempMapper mapper;
@Test
public void create() {
TempVO tempVO = TempVO.builder()
.title("test")
.content("test")
.build();
mapper.create(tempVO);
}
}
@AutoConfigureTestDatabase(replace= AutoConfigureTestDatabase.Replace.NONE) 어노테이션이 중요!