今天用mybatis逆向工程生成文件的时候,遇见这个错误
java.lang.IllegalStateException: Failed to load ApplicationContext
最开始在这里找 因为这里他加粗变颜色了
����: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactoryBean' defined in class path resource [spring-persist-mybatis.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\javasoft\xiangmucunfang\boot\atcrowd-funding-admin-parent\atcrowd-funding-admin-webui\target\classes\com\liuxia\mapper\TadminMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: XML fragments parsed from previous mappers already contains value for com.liuxia.mapper.TadminMapper.Example_Where_Clause
SqlSessionFacotoryBean加载不进容器,在spring.xml配置文件里找了许久 许久,确认好几次没问题
文件写错啊 数据源加载啊 扫描包啊 等等 全没问题
Caused by: java.lang.IllegalArgumentException: XML fragments parsed from previous mappers already contains value for com.liuxia.mapper.TadminMapper.Example_Where_Clause
最后总结吧
遇到BUG先从最下面的 Caused by去找造成原因
像这个 for com.liuxia.mapper.TadminMapper.Example_Where_Clause
明显是这个文件里出了问题 这是个接口
进去这个接口 TadminMapper 里面没有 Example_Where_Clause这个东西
然后进接口对应的 .XML文件
发现里面的方法都写了两遍
删除多的
问题解决
总结:BUG的出现,应该先从小的方面入手,由小及大,因为很多问题是小方面出现问题,导致大方面出现因为,会让你误以为是大的地方出现问题