Spring Boot中jar和war之间的区别? [英] Differences between jar and war in Spring Boot?

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

问题描述

我即将使用Spring Boot用Spring Framework用Java构建我的第一个网站,在jar中构建它要容易得多,但是我对此有一些疑问.

I'm about to build my first website in Java with Spring Framework using Spring Boot and it's much easier to build it in jar, but I have a few questions about it.

总体上有什么区别?

jar文件中,视图位于/resources/templates下,但在war文件中,视图位于/webapp/WEB-INF/下.

In jar files the views are under /resources/templates, but in war file it's under /webapp/WEB-INF/.

有什么区别?我可以在在线主机上部署jar吗?

What are the differences? Can I deploy a jar on an online host?

推荐答案

可以告诉Spring Boot生成一个胖JAR",其中包括您所有模块/服务的依赖项,并且可以与此处.

Spring Boot can be told to produce a 'fat JAR' which includes all of your module/service's dependencies and can be run with java -jar <your jar>. See "Create an executable JAR with Maven" here.

Spring Boot也可以被告知产生WAR文件,在这种情况下,您可能会选择将其部署到Tomcat或Jetty之类的Web容器中.

Spring Boot can also be told to produce a WAR file, in which case you'll likely choose to deploy it to a web container such as Tomcat or Jetty.

有关Spring Boot部署的更多详细信息此处

Plenty more details on Spring Boot deployment here.

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

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