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

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

问题描述

我即将使用 Spring Boot 使用 Spring 框架在 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 可以被告知生成一个fat JAR",其中包含所有模块/服务的依赖项,并且可以使用 java -jar .请参阅使用 Maven 创建可执行 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 文件,在这种情况下,您可能会选择将其部署到 Web 容器,例如 Tomcat 或 Jetty.

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天全站免登陆