iis服务器助手广告广告
返回顶部
首页 > 资讯 > 后端开发 > JAVA >SpringBoot启动失败Application run failed的解决办法
  • 599
分享到

SpringBoot启动失败Application run failed的解决办法

springbootmybatisjava 2023-10-08 21:10:30 599人浏览 八月长安
摘要

这个异常的问题源比较多,所以如果我的方法不能解决,请自行百度其他方法 文章目录 项目场景一:Application run failed问题描述:原因分析:解决方案: 场景分析二:A

这个异常的问题源比较多,所以如果我的方法不能解决,请自行百度其他方法

文章目录


项目场景一:Application run failed

提示:SpringBoot服务启动的时候报错:
这个问题遇到好多次了,一直没能记录下来,今天又碰到了
在这里插入图片描述

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.ERROR 1572 --- [  restartedMain] o.s.boot.springApplication               : Application run failed

问题描述:

SpringBoot 服务启动的时候报错:

下面是错误报告我用回车隔开方便检查

Error creating bean with name 'userAction': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'mapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userMapper' defined in file[E:\桌面\springbootdemo\target\classes\cn\edu\neu\springbootdemo\mapper\UserMapper.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: 'file [E:\桌面\springbootdemo\target\classes\mapper\UserMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 36;在 XML 声明中的编码伪属性前面必须有空格。

原因分析:

这个问题得具体问题具体分析,得看下面那些报错什么意思,不能直接去网上找解决办法
刚才也是找了好多博主写的文章都没解决
比如说我的报错信息是:
创建名为 “userAction” 的 bean 时出错
创建名为“userServiceImpl”的bean时出错
定义的名为“sqlSessionFactory”的bean时出错
在 XML格式声明中的编码伪属性前面必须有空格


解决方案:

检查代码(但我确实忘了这个项目是怎么调好的了😄)
但不是什么大错,很容易就改好了
在这里插入图片描述

场景分析二:Application run failed

在这里插入图片描述

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2022-10-14 13:15:21.461 ERROR 12548 --- [           main] o.s.boot.SpringApplication               : Application run failed

原因分析

往下看原因:Caused by:

下面是错误报告我用回车隔开方便检查

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/baomidou/mybatisplus/spring/boot/starter/MybatisPlusAutoConfiguration.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 com.baomidou.mybatisplus.exceptions.MybatisPlusException: Error: GlobalConfigUtils setMetaData Fail !  Cause:java.sql.SQLSyntaxErrorException: Unknown database 'jiakao'

重点在最后一句,他说我这个错误是:GlobalConfigUtils setMetaData失败!

原因:java.sql SQLSyntaxErrorException:未知数据库“jiakao”

解决办法

上面的错误说数据库名字不对

根据 Navicat或 VS Code数据库可视化工具一看,是数据库名字打错了

果然数据库名字一改后,立马跑通

总结

重要的不是问题解决了,重要的是解决问题的过程
还有error才会影响程序的运行,warning警告不用管
根据错误的提示去想,为什么找不到这个bean/class?通过这个错误一步步去跟踪,找到根本的原因,这是积累知识的过程
等以后这种问题发现地慢慢的多起来,慢慢地积累起来,积累的经验越多越好
英语很重要,不仅仅是处理问题的时候、出错的时候、分析问题的时候都是英文

来源地址:https://blog.csdn.net/rej177/article/details/127009245

--结束END--

本文标题: SpringBoot启动失败Application run failed的解决办法

本文链接: https://www.lsjlt.com/news/425688.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作