行业知识
服务启动未报错却自己终止
2026-11-13 17:50:00
来源:互联网转载
文章目录
- 一、问题场景
- 二、问题分析及解决
- 三、结束
一、问题场景
启动index.php/tags-1.html" >服务,没有报错,但是随即就终止了
Connected to the target VM, address: '127.0.0.1:52787', transport: 'socket'Disconnected from the target VM, address: '127.0.0.1:52787', transport: 'socket'
二、问题分析及解决
这其实是由于并没有真正启动 Spring Boot 应用程序
只需要加一行代码即可,其中UserApplication是你的当前服务名:
SpringApplication.run(UserApplication.class,args);
代码分析:
SpringApplication.run(UserApplication.class, args); 是 Spring Boot 应用程序的入口点。这行代码的作用是启动 Spring Boot 应用程序,并根据提供的配置类 UserApplication.class 来启动 Spring 应用程序。
在这行代码中,SpringApplication 是 Spring Boot 提供的一个类,其中的 run() 方法用于启动应用程序。在这里,它接收两个参数:配置类 UserApplication.class 和命令行参数 args。UserApplication.class 应该是一个包含了 Spring Boot 应用程序配置的类。
通过运行这行代码,Spring Boot 将会初始化应用程序,扫描并加载配置,启动服务器,并运行你的应用程序。
未加代码前:
补充代码后:
三、结束
任何疑问,欢迎私信指教!!!
分享:
才见迎梅又送梅,榴花五月雨中开。
江南芒种田家候,白下端阳客子杯。
下一篇:坦克世界哪里有服务器?