Public
Authored by 张律 💀

spring-boot 应用内存优化

为了节约资源, spring-boot 应用发布时尽量注意以下几点。

  1. 减少不必要的dependency
  2. 使用undertow替换tomcat作为嵌入式容器
  3. 修改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
52 Bytes
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment