Spring boot mybatisバージョンによる問題
3635 ワード
スプリングbootを使用してプロジェクトを統合するとき、次のような異常に遭遇しました.
異常情報によると、MybatisAutoConfigurationクラスでメソッド呼び出し異常が発生し、ソースコードを開いて表示
factoryが見つかりました.setVfs(SpringBootVFS.class)はSqlSessionFactoryBeanクラスに存在せず、sqlsesessionFactoryの作成に失敗しました.長い間悩んで、たくさんの資料を探して、spring bootバージョンを見て、またmybatis-spring-boot-starter統合パッケージのバージョンを見て、すべて問題がなくて、どうして私のプロジェクトが起動してこのような問題に遭遇しました!!仕方なく、以前のプロジェクトと現在のプロジェクト構造のmaven導入jarパッケージ構造を比較して、私は穴を開けました.の結果は親プロジェクトでこの依存性を定義したのです
坑父...もともと父の工事の中でここで幽霊を作って、取り除いた後、ここでmavenが導入したバージョンmybatis-spring-1.3を見ます.1,OK.万事順調で、正常に起動します.
2018-06-03 20:44:17.660 WARN 301924 ---
[ main] o.s.b.f.s.DefaultListableBeanFactory :
Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'roleDao' defined in file
[B:\workspace_spring\resume\baseservice\target\classes\com\ma\base\dao\RoleDao.class]:
Unsatisfied dependency expressed through bean property 'sqlSessionFactory';
nested exception is
Error creating bean with name 'sqlSessionFactory' defined in
class path resource
[org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]:
org.springframework.beans.BeanInstantiationException:
Factory method 'sqlSessionFactory' threw exception;
nested exception is java.lang.NoSuchMethodError:
org.mybatis.spring.SqlSessionFactoryBean.setVfs(Ljava/lang/Class;)V
異常情報によると、MybatisAutoConfigurationクラスでメソッド呼び出し異常が発生し、ソースコードを開いて表示
@Bean
@ConditionalOnMissingBean
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
SqlSessionFactoryBean factory = new SqlSessionFactoryBean();
factory.setDataSource(dataSource);
factory.setVfs(SpringBootVFS.class);
factoryが見つかりました.setVfs(SpringBootVFS.class)はSqlSessionFactoryBeanクラスに存在せず、sqlsesessionFactoryの作成に失敗しました.長い間悩んで、たくさんの資料を探して、spring bootバージョンを見て、またmybatis-spring-boot-starter統合パッケージのバージョンを見て、すべて問題がなくて、どうして私のプロジェクトが起動してこのような問題に遭遇しました!!仕方なく、以前のプロジェクトと現在のプロジェクト構造のmaven導入jarパッケージ構造を比較して、私は穴を開けました.の結果は親プロジェクトでこの依存性を定義したのです
<dependency>
<groupId>org.mybatisgroupId>
<artifactId>mybatis-springartifactId>
<version>1.2.2version>
dependency>
坑父...もともと父の工事の中でここで幽霊を作って、取り除いた後、ここでmavenが導入したバージョンmybatis-spring-1.3を見ます.1,OK.万事順調で、正常に起動します.