spring-boot 应用内存优化
为了节约资源, spring-boot 应用发布时尽量注意以下几点。
- 减少不必要的dependency
- 使用undertow替换tomcat作为嵌入式容器
- 修改jvm参数,减小最小占用的内存
pom.xml
<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-undertow</artifactId>
</dependency>
$java -Xmx128m -Xss256k -jar .\target\bishop-xxx.jar
Please register or sign in to comment