简体   繁体   English

带有.jar文件和Spring Boot的Confiusion

[英]Confiusion with .jar file and spring boot

I am a bit confused , why my application is working. 我有点困惑,为什么我的应用程序正常工作。 I have my spring boot project which compiles into .jar 我有我的spring boot项目,可以编译成.jar

<groupId>Twitter</groupId>
    <artifactId>twitter-api</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

and the application working fine (it's simple web app). 并且该应用程序正常运行(这是简单的网络应用程序)。 Thing I'm missing here is, why it is working while <packaging> is set to .jar and not .war (as for web app). 我在这里缺少的是为什么<packaging>设置为.jar而不是.war(对于Web应用程序)时它可以工作。 I mean to use it "normally" I'd put the .war file into webapp folder (talking about tomcat), and then access it xxxx/myapp. 我的意思是“正常”使用它,我会将.war文件放入webapp文件夹(谈论tomcat),然后访问xxxx / myapp。 But here Im packaging it into .jar and it's working as webapp. 但是在这里,我将其打包到.jar中,并且可以作为webapp使用。 Could someone explain me this? 有人可以解释一下吗? Thanks in advance folks! 在此先感谢大家!

Tomcat is running inside the JAR. Tomcat在JAR内部运行。 Spring Boot can run as an executable JAR without a Java EE app server or servlet/JSP engine. Spring Boot可以作为可执行JAR运行,而无需Java EE应用服务器或servlet / JSP引擎。

Normally Spring Boot embedd a servlet engine into your JAR and start your Application within this embedded servlet engine (Jetty, Tomcat). 通常,Spring Boot将servlet引擎嵌入到您的JAR中,然后在此嵌入式servlet引擎(Jetty,Tomcat)中启动应用程序。 Have a look at the Spring Boot Project . 看一下Spring Boot项目

This features are called 此功能称为

  • Create stand-alone Spring applications 创建独立的Spring应用程序
  • Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files) 直接嵌入Tomcat,Jetty或Undertow(无需部署WAR文件)

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

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