[英]Spring boot WAR size with different embedded servers
I am doing som experimentation with spring-boot and i realized that when i use embedded Tomcat server the resulting WAR size is smaller than when i use Jetty or even Undertow servers with same rest dependencies. 我正在使用spring-boot进行som实验,我意识到当我使用嵌入式Tomcat服务器时,生成的WAR大小比使用Jetty甚至Undertow服务器时具有相同的其他依赖性。
How is this possible? 这怎么可能? ... it is supposed that Undertow and Jetty should be ultralight compared with tomcat. ...与tomcat相比,Undertow和Jetty应该是超轻型的。
Sizes are: 尺码为:
Tomcat ~18Mb Tomcat~18Mb
Undertow ~21Mb 承诺~21Mb
Jetty ~24Mb 码头~24Mb
Any of them looks too big for me since this is dummy REST endpoint. 它们中的任何一个对我来说都太大了,因为这是虚拟REST端点。 These are my dependencies: 这些是我的依赖:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.springframework.boot</groupId> -->
<!-- <artifactId>spring-boot-starter-tomcat</artifactId> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>org.springframework.boot</groupId> -->
<!-- <artifactId>spring-boot-starter-undertow</artifactId> -->
<!-- </dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.springframework.boot</groupId> -->
<!-- <artifactId>spring-boot-starter-test</artifactId> -->
<!-- <scope>test</scope> -->
<!-- </dependency> -->
</dependencies>
Spring Boot includes three sample applications, spring-boot-sample-jetty
, spring-boot-sample-tomcat
, and spring-boot-sample-undertow
, with minimal, and pretty much identical, functionality. Spring Boot包括三个示例应用程序, spring-boot-sample-jetty
, spring-boot-sample-tomcat
和spring-boot-sample-undertow
,具有最小的,几乎完全相同的功能。 With Spring Boot 1.2.2.RELEASE, the archives sizes are: 使用Spring Boot 1.2.2.RELEASE,档案大小为:
spring-boot-sample-jetty
- 12MB spring-boot-sample-jetty
- 12MB spring-boot-sample-tomcat
- 9.8MB spring-boot-sample-tomcat
- 9.8MB spring-boot-sample-undertow
- 9.6MB spring-boot-sample-undertow
- 9.6MB As you can see Tomcat and Undertow are pretty much the same and the Jetty artifact is ~20% larger. 正如你所看到的,Tomcat和Undertow几乎相同,Jetty神器大约增加了20%。
One notable reason for the size difference is JSP support. 尺寸差异的一个值得注意的原因是JSP支持。 Undertow doesn't support JSPs and Spring Boot doesn't include Tomcat's JSP support by default. Undertow不支持JSP,Spring Boot默认不包括Tomcat的JSP支持。 ~1.7MB of the Jetty-based archive is taken up by the Eclipse Java compiler that's used for JSP compilation. ~7.7MB的基于Jetty的归档文件由用于JSP编译的Eclipse Java编译器占用。 If you want to use Jetty and aren't using JSPs, you could exclude the org.eclipse.jetty:jetty-jsp
dependency. 如果要使用Jetty并且不使用JSP,则可以排除org.eclipse.jetty:jetty-jsp
依赖项。 This reduces the Jetty-based artifact's size to 8.8MB. 这会将基于Jetty的工件的大小减小到8.8MB。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.