Springboot性能优化

1.扫包优化,是在启动的时候进行优化在使用@SpringBootApplication启动的时候一定要明确扫哪些包,不要都扫,自己可以测试一下看看启动时间,会提升很多.它这个扫包的原理就是扫同级包及其以下的所有包,如果不指定的话会扫很多无用的包.

2.jav参数调优

3.把内嵌服务器改为undertow

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <!--排除内置tomcat-->
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

引入undertow依赖

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-undertow</artifactId>
</dependency>

然后再测吞吐量会发现很高

猜你喜欢

转载自blog.csdn.net/kxj19980524/article/details/86756928