Found 5 relevant articles
-
Deep Dive into Spring Boot Application Startup: Complete Integration from Main Method to CommandLineRunner
This article provides an in-depth exploration of proper main method configuration in Spring Boot applications. Through analysis of common error cases, it explains the core role of SpringApplication.run(). The focus is on using @SpringBootApplication annotation to replace traditional configurations and achieving seamless integration of business logic with the Spring container via the CommandLineRunner interface. The article compares different startup strategies, offers complete code examples, and provides best practice guidance to help developers build command-line applications that align with Spring Boot design principles.
-
Multiple Approaches to Execute Code After Spring Boot Startup
This article provides an in-depth exploration of various methods to execute custom code after Spring Boot application startup, with focus on ApplicationReadyEvent listeners, CommandLineRunner interface, ApplicationRunner interface, and @PostConstruct annotation. Through detailed code examples and timing analysis, it explains the applicable scenarios, execution order, and best practices for different approaches, helping developers choose the most suitable post-startup execution strategy based on specific requirements.
-
Spring Boot Without Web Server: In-depth Analysis of Non-Web Application Configuration
This article comprehensively explores methods to disable embedded web servers in Spring Boot applications, focusing on the auto-configuration mechanism based on classpath detection. By analyzing the EmbeddedServletContainerAutoConfiguration source code, it reveals how Spring Boot intelligently decides whether to start a web container based on dependency presence, providing complete configuration solutions from Spring Boot 1.x to 3.x, covering property configuration, programmatic APIs, and CommandLineRunner implementation patterns.
-
Complete Guide to Loading @Value Properties from YAML Files in Spring Boot
This article provides an in-depth exploration of the mechanisms for loading @Value properties from YAML configuration files in Spring Boot applications. Through analysis of a typical configuration loading failure case, it explains YAML file format requirements, Spring Boot property loading order, and correct usage of the @Value annotation. The article also discusses timing issues when accessing @Value properties in constructors and provides practical solutions.
-
Complete Guide to Consuming RESTful Web Services in Java
This article provides a comprehensive overview of consuming RESTful web services in Java, covering basic implementations using HttpURLConnection, JAX-RS client APIs, and advanced abstractions with Spring RestTemplate. Through detailed code examples and technical analysis, it helps developers choose the best approach for different scenarios.