mybatis mapper์์ requestType์ด๋ parameterType์ผ๋ก ํด๋์ค๋ฅผ ์ฐธ์กฐํ ๋ ๋ค์๊ณผ ๊ฐ์ด ํจํค์ง๋ช ์ ๋ค ์จ์ค์ผํ๋ ๋ถํธํจ์ด ์๋ค.
<mapper namespace="com.hello.spring.article.mapper.ArticleMapper">
<select id="selectArticles" resultType="com.hello.spring.article.dto.ArticleDto">
...์ด๋ด ๋ application.properties์์ ๋ค์๊ณผ ๊ฐ์ด ์ค์ ํด์ฃผ๋ฉด ์ฟผ๋ฆฌ ํ๊ทธ์์๋ ํจํค์ง๋ช
์ ์จ์ฃผ์ง ์๊ณ ํด๋์ค๋ช
๋ง ์จ์ค๋ ๋๋ค.
mybatis.type-aliases-package=com.hello.spring<mapper namespace="com.hello.spring.article.mapper.ArticleMapper">
<select id="selectArticles" resultType="ArticleDto">
...์คํ๋ง์์ mybatis.type-aliases-package์ ์ค์ ๋ ํจํค์ง๋ฅผ ๋ณด๊ณ ๊ทธ ํ์ ๊ฒฝ๋ก์์ ํด๋์ค๋ฅผ ์ฐพ๋ ๋ฐฉ์์ด๋ค.
์ฃผ์์
mybatis.type-aliases-package์์ ์ค์ ํ ํจํค์ง ํ์ ๊ฒฝ๋ก๋ฅผ ๋ชจ๋ ์ดํด๋ณด๋ ๋ฐฉ์์ผ๋ก ๋์ํ๋ฏ๋ก, ๊ฐ์ ํด๋์ค๊ฐ ๋ ๊ฐ ์ด์ ์กด์ฌํ๋ฉด ์๋ฌ๊ฐ ๋๋ค.
// ํ์ผ๊ตฌ์กฐ
dto
> test
> ArticleDto
> ArticleDto
Caused by: org.apache.ibatis.type.TypeException: The alias 'ArticleDto' is already mapped to the value 'com.hello.spring.article.dto.ArticleDto'.
์ด๋ด ๋ ์๋์ ๊ฐ์ด ๋ ์ค ํ๋๋ฅผ @Alias ์ ๋
ธํ
์ด์
์ผ๋ก ๋ค๋ฅธ ์ด๋ฆ์ผ๋ก ์ง์ ํด์ฃผ๋ฉด ํด๊ฒฐ๋๋ค.
@Alias("ArticleDto2")
public class ArticleDto