springBoot项目使用maven打jar包出错(其中一种情况)

报错信息如下

org.springframework.core.NestedIOException: Failed to parse mapping resource: 'class path resource [mapper/appfaceMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'appface'.  Cause: java.lang.ClassNotFoundException: Cannot find class: appface


caused by: java.lang.ClassNotFoundException: Cannot find class: SetMeal
  
翻译如下
org.springframework.core.nestedioException:未能分析映射资源:“类路径资源(其实是映射到了appfacemapper.xml文件了)

[mapper/appfacemapper.xml]”;嵌套异常为org.apache.ibatis.builder.builderException:分析映射器xml时出错。

原因:org.apache.ibatis.builder.builderException:解析类时出错。
原因:org.apache.ibatis.type.typeexception:未能解析类型别名“appface”。
原因:java.lang.ClassNotFoundException:找不到类:AppFace




原因:java.lang.ClassNotFoundException:找不到类:setMeal

前提:使用springboot 插件打jar包

jar包能打成功 在cmd里运行jar包报上面的错

             <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin> 


   <properties>
        <commons-lang.version>2.6</commons-lang.version>
        <jackson.library>2.7.5</jackson.library>

        <!-- The main class to start by executing java -jar(jar成jar包后的程序入口) -->
        <start-class>com.bms.Application</start-class>
    </properties>

解决办法

因为mapper.xml都是逆向生成的 所以  你只需要关注你自己手动写的sql语句

检查resultType这个类型 你是否用的全名 没有要加全名应该就能成功了

cmd 运行 到你所打的jar包路劲在  java -jar XXX.jar


版权声明:本文为weixin_36731461原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。