org.apache.ibatis.type.TypeException:别名“ Criterion”已经映射到值“ com.xxx.domain.def.GameListExample $ Criterion”

时间:2019-04-29 12:03:31

标签: spring-boot mybatis

我使用mybatis生成器生成域和映射器。当我生成一张表时,它工作得很好。

当我生成另一个表时,问题来了。看来GameListExample和BetRecdExample中的Criterion类发生冲突,但这是由mybatis生成的。

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'betRecdMapper' defined in file 
[F:\IdeaProjects\game\target\classes\com\good\game\dao\def\BetRecdMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource 
[org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: 
Factory method 'sqlSessionFactory' threw exception; nested exception is org.apache.ibatis.type.TypeException: The alias 'Criterion' is already mapped to the value 'com.good.game.domain.def.GameListExample$Criterion'.

1 个答案:

答案 0 :(得分:0)

听起来像与https://github.com/mybatis/generator/issues/461相同的问题

这是由于mybatis-spring 2.0.1。中的错误引起的。
https://github.com/mybatis/spring/issues/362
当前的解决方法是使用mybatis-spring 2.0.0或2.0.2-SNAPSHOT。