关于springboot项目的jar和war两种打包方式部署的区别

关于springboot项目的jar和war两种打包方式部署的区别?

https://bbs.csdn.net/topics/392493467

 

1.我的一个springboot项目,用mvn install打包成jar,换一台有jdk的机器就直接可以用java -jar 项目名.jar的方式运行,没任何问题,为什么这里不需要tomcat也可以运行了?

 

<dependency>

    <groupId>org.springframework.boot</groupId>

    <artifactId>spring-boot-starter-web</artifactId>

</dependency>

 

依赖下面这个:

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-tomcat -->

<dependency>

    <groupId>org.springframework.boot</groupId>

    <artifactId>spring-boot-starter-tomcat</artifactId>

    <version>2.1.6.RELEASE</version>

</dependency>

 

这个又依赖下面这几个:

Apache 2.0 org.apache.tomcat.embed » tomcat-embed-core

 

Apache 2.0 org.apache.tomcat.embed » tomcat-embed-el

 

Apache 2.0 org.apache.tomcat.embed » tomcat-embed-websocket

 

所有 最终 还是有依赖tomcat的,只不过是内置的

 

要是打war包,是要排除内置的tomcat的

 

 

 

spring boot 打成jar包的时候,你可以看一下pom文件,在pom里面有一些tomcat的jar包引用,就是Spring boot内置的tomcat,

打war包时,需要注释掉这些tomcat的引用

相关文章:

  • 2021-04-29
  • 2021-05-25
  • 2021-10-20
  • 2022-02-10
  • 2021-12-06
  • 2021-11-29
  • 2021-08-11
猜你喜欢
  • 2021-08-29
  • 2021-06-24
  • 2022-01-11
  • 2022-12-23
  • 2021-12-26
  • 2021-07-05
  • 2021-10-28
相关资源
相似解决方案