简体   繁体   English

“运行方式:Spring Boot应用程序”和“运行方式:Java应用程序”之间有区别吗?

[英]Is there a difference between Run As: Spring Boot App and Run As: Java Application?

If I am using Spring Tool Suite or The Spring IDE plugin for eclipse, I can run a spring boot app 2 ways: 如果我使用的是Spring Tool Suite或The Spring IDE插件来运行Eclipse,则可以通过2种方式运行spring boot应用程序:

Run As:
    Spring Boot App
    Java Application

在此处输入图片说明

Both of these commands work and can fire up my spring boot app without an issue. 这两个命令都可以正常工作,并且可以启动我的spring boot应用程序。 However, I wanted to understand the difference between the two different processes. 但是,我想了解两个不同过程之间的区别。 Is there actually a difference between them or do they work identically? 它们之间实际上有区别还是它们工作相同?

There are couple of differences, as someone already hinted in a comment. 正如有人已经在评论中暗示的那样,存在一些差异。 This article explains that you get some extra 'Bells and Whistles' in the launch configuration editor. 本文介绍,您在启动配置编辑器中会得到一些额外的“钟声和口哨声”。

A second and perhaps more important difference is that since Boot 1.3 there is a JMX bean provided by Spring Boot App that allows STS to ask the app nicely to shut down. 第二个也许是更重要的区别是,从Boot 1.3开始,Spring Boot App提供了一个JMX bean,它允许STS很好地要求该应用关闭。 When you terminate the app from the IDE, for example by clicking the stop / restart button, STS uses this JMX bean to ask the boot app to shut down. 当您从IDE终止应用程序时,例如通过单击“停止/重新启动”按钮,STS使用此JMX Bean要求引导应用程序关闭。 This is a feature implemented in the "Run As Boot App" launcher, and so it doesn't take effect if you use "Run As Java App". 此功能是在“运行方式启动应用程序”启动程序中实现的,因此,如果使用“运行方式Java应用程序”,该功能不会生效。

The Java launcher simply terminates the process associated with the launch using Java's Process.destroy() method. Java启动器仅使用Java的Process.destroy()方法终止与启动相关的过程。 This is a more 'aggressive' way to kill the associated process and may not allow the app to cleanup stuff properly, for example cleanly closing database connnections. 这是杀死关联进程的一种更“激进”的方式,并且可能不允许该应用正确清理内容,例如干净关闭数据库连接。

So... in summary you get two things: 所以...总而言之,您得到两件事:

  1. Some extra boot-specific UI in the launch conf editor 启动配置文件编辑器中的一些额外的特定于启动的UI
  2. Graceful process termination for Boot 1.3 and later. Boot 1.3和更高版本的正常进程终止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM