個人spring boot + mybatis項目在idea裏面執行正常,但發佈測試環境打成可執行jar包後就啓動失敗,提示錯誤以下:java
[ 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屬性中使用spring
<select id="find" resultType="HotelOrdersModel">
這裏不該該只寫類名,而應該寫全完整類名,就是包含包名的類名sql
<select id="find" resultType="com.ysl.ts.core.model.hotel.ts_hotel_order.HotelOrdersModel">
這樣修改完成後再打包發佈執行就解決了。express