Run As: Spring Boot App 和 Run As: Java Application 之间有区别吗? [英] Is there a difference between Run As: Spring Boot App and Run As: Java Application?

查看:79
本文介绍了Run As: Spring Boot App 和 Run As: Java Application 之间有区别吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我使用 Spring Tool Suite 或 The Spring IDE 插件进行 Eclipse,我可以通过 2 种方式运行 Spring Boot 应用程序:

If I am using Spring Tool Suite or The Spring IDE plugin for eclipse, I can run a spring boot app 2 ways:

Run As:
    Spring Boot App
    Java Application

这两个命令都可以正常工作,并且可以毫无问题地启动我的 Spring Boot 应用程序.但是,我想了解两个不同过程之间的区别.它们之间实际上有区别还是它们的工作原理相同?

Both of these commands work and can fire up my spring boot app without an issue. However, I wanted to understand the difference between the two different processes. Is there actually a difference between them or do they work identically?

推荐答案

有几个不同之处,正如有人已经在评论中暗示的那样.这篇文章 说明您在启动配置编辑器中获得了一些额外的Bells and Whistles".

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.

第二个也许更重要的区别是,从 Boot 1.3 开始,Spring Boot App 提供了一个 JMX bean,它允许 STS 很好地要求应用程序关闭.当您从 IDE 终止应用程序时,例如通过单击停止/重新启动按钮,STS 使用此 JMX bean 要求启动应用程序关闭.这是在Run As Boot App"启动器中实现的功能,因此如果您使用Run As Java App",它不会生效.

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. 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. 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 启动器使用 Java 的 Process.destroy() 方法.这是杀死相关进程的更激进"的方式,并且可能不允许应用程序正确清理内容,例如干净地关闭数据库连接.

The Java launcher simply terminates the process associated with the launch using Java's Process.destroy() method. 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. 启动配置编辑器中一些额外的特定于启动的 UI
  2. Boot 1.3 及更高版本的正常进程终止.

这篇关于Run As: Spring Boot App 和 Run As: Java Application 之间有区别吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆