最近在sprootboot的項目中將使用mybatisplus框架中的代碼生成模塊中,執行完代碼生成程序以后,運行程序后報一下錯誤:org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'shirFilter' defined in class path resource [com/mingqi/author/shiro/config/ShiroConfig.class]: Unsatisfied dependency expressed through method 'shirFilter' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'securityManager' defined in class path resource [com/mingqi/author/shiro/config/ShiroConfig.class]: Unsatisfied dependency expressed through method 'getDefaultWebSecurityManager' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bdpUserRealm': Unsatisfied dependency expressed through field 'isAuUserService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.mingqi.author.service.impl.SAuUserServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'SAuUserMapper' defined in URL [jar:file:/D:/maven/repository/com/mingqi/framework/author/2.0.4/author-2.0.4.jar!/com/mingqi/author/dao/SAuUserMapper.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 [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.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.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\work\Service\target\classes\mapper\ReviewtitleTalBatchMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'file [D:\work\Service\target\classes\mapper\ReviewtitleTalBatchMapper.xml]'. Cause: java.lang.IllegalStateException: No typehandler found for property batchcontext
剛開始一直以為是文件名和框架jar包中封裝類的名字重復了或者是類的名稱和mapper中的xml的文件不一致導致的,檢查了一遍又一遍,還是沒有發現問題。最后知道無意間看到了Cause: java.lang.IllegalStateException: No typehandler found for property batchcontext 這句話,大致的意思是說找不到屬性的類型處理程序,然后我就在ReviewtitleTalBatchMapper.xml這個文件中找到了batchcontext 這個屬性:
去對應的ReviewtitleTalBatch 實體類中看了一下他的類型為:Blob,如下圖(該類型由代碼生成器自動生成的,為oracle數據庫中的大字段的類型):
在Java中沒有這個類型,嘗試將該類型修改為String,同時修改對應的get和set方法,然后重新啟動項目,啟動成功。