我想针对低性能硬件优化 Spring 引导。我只是将 JDBC 用于 SqlLite 数据库。看起来一开始就失去了 5 分钟,我不确定在哪里或为什么。如果有人可能有任何建议。我看到了其他想法,但我不确定它是否适用于我拥有 Raspberry Pi 1 性能的情况。
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.2.RELEASE)
2021-08-02 14:18:55.075 INFO 24149 --- [ main] com.app.AppGatewayApplication : Starting AppGatewayApplication v0.0.1-SNAPSHOT with PID 24149 (/opt/app/app.jar started by root in /opt/app)
**2021-08-02 14:18:55.261 INFO 24149 --- [ main] com.app.AppGatewayApplication : No active profile set, falling back to default profiles: default
2021-08-02 14:22:46.915 WARN 24149 --- [ main] io.undertow.websockets.jsr : UT026010: Buffer pool was not set on WebSocketDeploymentInfo, the default pool will be used**
2021-08-02 14:22:51.668 INFO 24149 --- [ main] io.undertow.servlet : Initializing Spring embedded WebApplicationContext
2021-08-02 14:22:51.671 INFO 24149 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 230771 ms
2021-08-02 14:23:37.337 INFO 24149 --- [ main] o.f.c.internal.license.VersionPrinter : Flyway Community Edition 6.5.5 by Redgate
2021-08-02 14:23:45.163 INFO 24149 --- [ main] o.f.c.internal.database.DatabaseFactory : Database: jdbc:sqlite:data/app.db (SQLite 3.32)
2021-08-02 14:23:49.716 INFO 24149 --- [ main] o.f.core.internal.command.DbValidate : Successfully validated 19 migrations (execution time 00:02.585s)
2021-08-02 14:23:49.962 INFO 24149 --- [ main] o.f.core.internal.command.DbMigrate : Current version of schema "main": 1.1.19
2021-08-02 14:23:50.027 INFO 24149 --- [ main] o.f.core.internal.command.DbMigrate : Schema "main" is up to date. No migration necessary.
2021-08-02 14:23:51.952 INFO 24149 --- [ main] com.app.repository.e : Connection - - - - - - - - New DBConnection created
最佳答案
除非您知道造成时间损失的原因,否则很难提高性能。
因此,我会先提高日志级别,以了解那段时间到底发生了什么。弄清楚这一点后,您就可以考虑如何提高性能了。
此外,从2.4版本开始,Spring Boot提供了一些方法来了解服务启动过程中发生了什么,以及每一步需要多长时间。例如,您可以在这里找到有关如何将此监控构建到您的服务中的一些提示:https://www.amitph.com/spring-boot-startup-monitoring/
关于java - 针对低性能硬件优化 spring boot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68623531/