zoukankan      html  css  js  c++  java
  • spring boot mybatis 打成可执行jar包后启动UnsatisfiedDependencyException异常

    我的spring boot + mybatis项目在idea里面执行正常,但发布测试环境打成可执行jar包后就启动失败,提示错误如下:

    [ ERROR] [2018-08-30 17:23:48] org.springframework.boot.SpringApplication [845] - Application run failed
    
    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bookingController': Unsatisfied dependency expressed through field 'service'; 
    
    nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bookingService': Unsatisfied dependency expressed through field 'mapper'; 
    
    nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'citiesMapper' defined in URL [jar:file:/D:/Code/YSL_TravelSupport_CodeSource
    /trunk/src/YSL_TS_Java/start-bat/ysl-ts-core-service-hotel-1.0-SNAPSHOT.jar!/BOOT-INF/classes!/com/ysl/ts/core/service/hotel/mapper/ts_hotel/CitiesMapper.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/ysl/ts/core/service/hotel/config/HotelMybatisPlusConfig.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: 'class path resource [mapper/ts_hotel_order/HotelRefundMoneyTaskMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'class path resource [mapper/ts_hotel_order/HotelRefundMoneyTaskMapper.xml]'.
    Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'HotelOrdersModel'.
    Cause: java.lang.ClassNotFoundException: Cannot find class: HotelOrdersModel

    最后有一句写着:Cannot find class: HotelOrdersModel 找不到HotelOrdersModel类,打开这个mapper xml看到这里类在一个sql的resultType属性中使用

    <select id="find" resultType="HotelOrdersModel">

    这里不应该只写类名,而应该写全完整类名,就是包含包名的类名

    <select id="find" resultType="com.ysl.ts.core.model.hotel.ts_hotel_order.HotelOrdersModel">

    这样修改完成后再打包发布执行就解决了。

  • 相关阅读:
    C#判断是否运行在调试模式下
    [php] Interface abstract里面的私有方法 private method of interface and abstract class
    [html] Javascript warning and error of w3c
    [html] <a> and <input> can not click in IE6 when use png fixed IE6下png图片和png背景透明导致该区域的链接和按钮无效
    [Ubuntu] invalid environment block
    [Ubuntu] 分割与合并文件 Cut and mix the file
    [php] Treat an object like an array
    [eZ publish] How to add a element to an array.
    [html] PHP使用Google map web services来计算两点间的距离 Compute the distance between two place via Google map services in PHP
    [html] symbol of <b> and <strong>
  • 原文地址:https://www.cnblogs.com/taiyonghai/p/9564310.html
Copyright © 2011-2022 走看看