springboot/mybatis在idea中运行OK打包test也OK但命令行运行jar却报错

新手上路,请多包涵
2019-12-17 12:43:20.834 ERROR 4644 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'asyncTaskServiceImpl': Injection of resource dependencies failed; 
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mailServiceImpl' defined in URL [jar:file:/D:/Projects/github/presevere/presevere-server/target/presevere-server-1.0.0.jar!/BOOT-INF/classes!/cn/gmwenterprise/presevere/service/impl/MailServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; 
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'systemConfig': Injection of resource dependencies failed; 
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sysUserMapper' defined in URL [jar:file:/D:/Projects/github/presevere/presevere-server/target/presevere-server-1.0.0.jar!/BOOT-INF/classes!/cn/gmwenterprise/presevere/dao/SysUserMapper.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 [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.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 [mappers/]'; 
nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; 文件提前结束。

以上就是异常栈的主要信息,从中我现在已经看不出任何有效信息了。
怀疑过mappers文件夹中mapper.xml的编码问题,经vscode、notepad++等工具检查确认了编码的确是UTF-8 with NO BOM,所有mapper都是generate生成的,打包用的jdk试过了8和11,都一样会报这个错。

image.png
这张图片是打包时的信息,可见打包过程中的test也是OK的。

delete from sys_user_role where user_id not in ( ?, ?, ? )

其中这一行代码是我写在一个Configuration中的,是为了方便测试时清除无效数据使用,这个代码就是调用了mapper中的sql。
image.png

综上所述,求大佬救命!!!

阅读 5.3k
2 个回答
新手上路,请多包涵

最后问题解决了,是因为,resources下没有mybatis的配置文件。为啥没有配置文件就不能用命令行启动jar包,我也不知道。采纳的答案是因为解决时就只有一个回答........

推荐问题