[英]Spring boot WAR size with different embedded servers
我正在使用spring-boot進行som實驗,我意識到當我使用嵌入式Tomcat服務器時,生成的WAR大小比使用Jetty甚至Undertow服務器時具有相同的其他依賴性。
這怎么可能? ...與tomcat相比,Undertow和Jetty應該是超輕型的。
尺碼為:
Tomcat~18Mb
承諾~21Mb
碼頭~24Mb
它們中的任何一個對我來說都太大了,因為這是虛擬REST端點。 這些是我的依賴:
<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包括三個示例應用程序, spring-boot-sample-jetty
, spring-boot-sample-tomcat
和spring-boot-sample-undertow
,具有最小的,幾乎完全相同的功能。 使用Spring Boot 1.2.2.RELEASE,檔案大小為:
spring-boot-sample-jetty
- 12MB spring-boot-sample-tomcat
- 9.8MB spring-boot-sample-undertow
- 9.6MB 正如你所看到的,Tomcat和Undertow幾乎相同,Jetty神器大約增加了20%。
尺寸差異的一個值得注意的原因是JSP支持。 Undertow不支持JSP,Spring Boot默認不包括Tomcat的JSP支持。 ~7.7MB的基於Jetty的歸檔文件由用於JSP編譯的Eclipse Java編譯器占用。 如果要使用Jetty並且不使用JSP,則可以排除org.eclipse.jetty:jetty-jsp
依賴項。 這會將基於Jetty的工件的大小減小到8.8MB。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.