Skip to content

Spring Boot Reference Documentation

reading list

  • Documentation Overview : 總覽
    • spring-cli 可以直接 run groovy
  • Getting Started : Introducing Spring Boot, System Requirements, Servlet Containers, Installing Spring Boot, and Developing Your First Spring Boot Application
  • Using Spring Boot : Build Systems, Structuring Your Code, Configuration, Spring Beans and Dependency Injection, DevTools, and more. : 開發一個springboot流程
  • Core Features :Profiles, Logging, Security, Caching, Spring Integration, Testing, and more.
    • ApplicationContextEvent 不能用 @Bean 創建
    • META-INF/spring.factories : org.springframework.context.ApplicationListener=com.example.project.MyListener
    • ApplicationRunner or CommandLineRunner
    • @DataElasticsearchTest , @DataJpaTest , @DataJdbcTest
  • Web :Servlet Web, Reactive Web, GraphQL, Embedded Container Support, Graceful Shutdown, and more.
    • mvc
      • Spring MVC 自動配置
        • ContentNegotiatingViewResolver and BeanNameViewResolver
        • static resources, including support for WebJars
        • ConverterGenericConverter, and Formatter beans
        • HttpMessageConverters
        • MessageCodesResolver
        • ConfigurableWebBindingInitializer
      • ErrorViewResolver :  @ExceptionHandler , @ControllerAdvice
    • shutdown
    • web security
    • web sesion
  • Data :SQL and NOSQL data access.
    • jpa
    • jdbc
    • jooq
    • r2dbc
    • redis
    • mongodb
    • neo4j
    • elasicsearch
    • couchbase
    • ldap
    • infucdb
  • IO Caching, Quartz Scheduler, REST clients, Sending email, Spring Web Services, and more.
    • cache provider
      • generic : CacheManager : org.springframework.cache.Cache
      • jcache : JCacheCacheManager : spring.cache.jcache.provider
      • quartz
      • email
      • restTemplate
      • webClient
      • JTA
  • Messaging :JMS, AMQP, Apache Kafka, RSocket, WebSocket, and Spring Integration.
  • Container Images : build docker image , fat jar
  • Production-ready Features :
    • 監控 Monitoring,
    • Metrics,
    • Auditing, and more.
  • Deploying Spring Boot Applications :Deploying to the Cloud, and Installing as a Unix application.
    • k8s : Kubernetes Container Lifecycle
    • Heroku

“How-to” Guides

  • 1. Spring Boot Application
    • FailureAnalyzer 用來分析啟動錯誤
      • org.springframework.boot.diagnostics.FailureAnalyzer=com.example.ProjectConstraintViolationFailureAnalyzer
      • If you need access to the BeanFactory or the Environment, your FailureAnalyzer can implement BeanFactoryAware or EnvironmentAware respectively.
    • 經驗法則
      • 查找調用的類 *AutoConfiguration 並閱讀它們的來源。請特別注意 @Conditional* 註釋以了解它們啟用了哪些功能以及何時啟用。
      • 添加 --debug 到命令行或系統屬性 -Ddebug 以在控制台上獲取在您的應用程序中做出的所有自動配置決策的日誌。
      • 在啟用了執行器的正在運行的應用程序中,查看 conditions 端點(/actuator/conditions 或 JMX 等效項)以獲取相同的信息。
      • 查找類@ConfigurationProperties(例如 ServerProperties)並從那裡讀取可用的外部配置選項。
      • @ConfigurationProperties 註釋有一個 name 作為外部屬性前綴的屬性。因此,ServerPropertieshasprefix="server" 及其配置屬性是 server.port、server.address 和其他。在啟用執行器的運行應用程序中,查看 configprops 端點。
      • 尋找該 bind 方法的用途,以輕鬆的方式 Binder 顯式地將配置值拉出。Environment 它通常與前綴一起使用。
      • 查找@Value 直接綁定到 Environment.
      • 查找@ConditionalOnExpression 響應 SpEL 表達式打開和關閉功能的註釋,通常使用從 Environment.
  • 2. Properties and Configuration
    • maven gradle 設定的屬性可以傳入 application.yaml 中
    • 設定檔會全部合併
  • 3. Embedded Web Servers
    • Undertow
    • response 壓縮設定
  • 4. Spring MVC
  • 5. Jersey
  • 6. HTTP Clients
  • 7. Logging
  • 8. Data Access
  • 9. Database Initialization
  • 10. Messaging
  • 11. Batch Applications
  • 12. Actuator
  • 13. Security
  • 14. Hot Swapping
  • 15. Testing
  • 16. Build
  • 17. Traditional Deployment