小工具知识网

当前位置: 首页 > 行业知识 > Tc0.Springboot项目启动失败

行业知识

Tc0.Springboot项目启动失败

2026-11-10 15:30:43 来源:互联网转载

问题:IDEA调试Springboot项目启动失败:已与地址为 ‘‘127.0.0.1:12574’,传输: ‘套接字’’ 的目标虚拟机断开连接

一、现象描述

  • IDE(IDEA或者Eclipse)调试模式

    博主使用的是IDEA 2023社区版:已与地址为 ‘‘127.0.0.1:12574’,传输: ‘套接字’’ 的目标虚拟机断开连接

    或者

    Disconnected from the target VM, address: ‘127.0.0.1:56065’, transport: ‘socket’

    二、问题分析

    网络常见问题原因:

    1. 缺少依赖项
    2. java和tomcat版本不匹配
    3. 端口占用
    4. 使用maven打包程序
    5. (重要)此问题还有可能是以下几个问题产生,导致项目运行失败。需进一步排查。

    总结概括就是,检查jar包冲突与缺少的依赖项目。

    三、解决方案

    缺少依赖项解决方法:

    首先编辑pom文件,父级依赖及spring-web启动器依赖

                org.springframework.boot        spring-boot-starter-parent                2.6.3                            org.springframework.boot            spring-boot-starter-web            

    导入依赖 ,加载maven更改。

    java和tomcat版本不匹配

    检查版本

    java -versionjavac -version
    端口占用
    netstat -an | grep 端口号

    如有有占用,杀***相应进程

    使用maven打包程序
    java -jar D:\Work\Code\java\demo\target\demo-0.0.1-SNAPSHOT.jar

    有些时候,idea启动不了,但是命令行可以启动

    问题:Springboot项目打包出错:Please refer to XXX\target\surefire-reports for the inpidual test results

    一、现象描述

    详细提示

    Please refer to D:\Work\java\demo\target\surefire-reports for the inpidual test results.Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.

    二、问题分析

    出错的原因,是该项目存在一些异常错误。

    三、解决方案

    方法一:依次排查pom依赖项,找到项目出现了异常。

    方法二:使用maven的配置来将测试错误忽略掉。

    方法三: java/demo/pom.xml文件中,添加属性,并设置为true。然后刷新pom.xml。

    17true

    此方法虽然可以完成打包,但是如果包还是有错,执行时还是会出错。具体参考下面的问题。

    问题:Springboot项目调试出错java.lang.NoClassDefFoundError: javax/servlet/ServletRequest

    一、现象描述

    在上面的打包出错的时候,调试会发生如下错误:

    java.lang.NoClassDefFoundError: javax/servlet/ServletRequestat org.springframework.web.context.support.WebApplicationContextUtils.registerWebApplicationScopes(WebApplicationContextUtils.java:195) ~[spring-web-5.3.15.jar:5.3.15]at org.springframework.web.context.support.WebApplicationContextUtils.registerWebApplicationScopes(WebApplicationContextUtils.java:174) ~[spring-web-5.3.15.jar:5.3.15]at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.registerWebApplicationScopes(ServletWebServerApplicationContext.java:254) ~[spring-boot-3.2.0.jar:3.2.0]at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.postProcessBeanFactory(ServletWebServerApplicationContext.java:140) ~[spring-boot-3.2.0.jar:3.2.0]at org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext.postProcessBeanFactory(AnnotationConfigServletWebServerApplicationContext.java:200) ~[spring-boot-3.2.0.jar:3.2.0]at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:593) ~[spring-context-6.1.1.jar:6.1.1]at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.2.0.jar:3.2.0]at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:753) ~[spring-boot-3.2.0.jar:3.2.0]at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:455) ~[spring-boot-3.2.0.jar:3.2.0]at org.springframework.boot.SpringApplication.run(SpringApplication.java:323) ~[spring-boot-3.2.0.jar:3.2.0]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1342) ~[spring-boot-3.2.0.jar:3.2.0]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1331) ~[spring-boot-3.2.0.jar:3.2.0]at com.example.demo.DemoApplication.main(DemoApplication.java:10) ~[classes/:na]Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletRequestat java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[na:na]... 13 common frames omitted

    二、问题分析

    即使使用上面的方法打包成功,执行时仍然会报这个错。

    此错误原始意思时jvm运行找不到这个类。

    三、解决方案

    编译时缺少或者运行时缺少,运行缺少主要可能是配置不对。

    使用maven分析依赖关系。查看具体冲突的依赖。

      javax.servlet  javax.servlet-api  3.1.0

    问题:Springboot项目maven出错

    一、现象描述

    运行重新加载所有Maven项目,报错如下

    无法解析插件 org.apache.maven.plugins:maven-site-plugin:3.12.1尝试使用 -U 标记(强制更新快照)运行 Maven 导入

    二、问题分析

    不影响打包

    三、解决方案

    无。

    问题:使用npm安装axios之后出错

    一、现象描述

     ERROR  Failed to compile with 1 errors                           下午1:06:04 error  in ./node_modules/axios/lib/platform/index.jsModule parse failed: Unexpected token (5:2)

    二、问题分析

    这个错误也有很多情况,其中之一:npm安装了一个包,然后在导入的时候报这个语法错。

    三、解决方案

    npm list 查看的包名       #查看安装版本npm view 查看的包名 version #查看最新版本npm view 查看的包名 versions    #这个会查到npm服务器上对应查询包的版本所有信息npm uninstall axios  #卸载安装的版本npm install axios@1.5.0 --save #下载对应的版本

上一篇:易企秀手机特效制作大揭秘!

下一篇:揭秘PHP算命网站背后的技术秘密,探寻命运之轮源码揭秘!