如何優化SpringBoot的項目的啟動速度


日常開發SpringBoot項目啟動類都用@SpringBootApplication,實際上它是下面三個注解的組合:
啟動慢往往跟 @ComponentScan和 @EnableAutoConfiguration加載的內容太多有關,一種方法是不用這兩個注解,通過@import注解精確指定要加載掃描的類,但要加載的類多時又很麻煩,
可以用@SpringBootApplication注解下面的屬性:
  • exclude: Exclude the list of classes from the auto configuration.
  • excludeNames: Exclude the list of fully qualified class names from the auto configuration. This parameter added since spring boot 1.3.0.
  • scanBasePackageClasses: Provide the list of classes that has to be applied for the @ComponentScan.
  • scanBasePackages Provide the list of packages that has to be applied for the @ComponentScan. This parameter added since spring boot 1.3.0.
另外,如果SpringBoot項目啟動很慢, 可能 意味着你要重新拆分微服務。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM