端口被占用或提示如下报错信息:
【报错信息1】
Error creating bean with name 'sqlSessionFactory' defined in class path resource [config/db/db.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [config/db/db.xml]: Invocation of init method failed; nested exception is java.sql.SQLException: interrupt

【报错信息2】The Tomcat connector configured to listen on port 8080 failed to start...
(1)搜索框输入cmd打开命令提示符,输入命令netstat -aon|findstr "端口号"查询被占用端口的进程号
netstat -aon|findstr "8080"
(2)找到端口号对应的pid,使用命令taskkill /pid XXXX /f终止该进程
taskkill /pid XXXX /f

最后重启项目即可
本文介绍如何在遇到Spring Boot中'端口被占用'和'dataSource初始化失败'的问题时,通过查询占用端口、终止进程并重启项目来解决。步骤包括使用`netstat`检查端口占用情况,`taskkill`关闭进程,以及排查`dataSouce`配置错误。
1万+

被折叠的 条评论
为什么被折叠?



