S SmartDocs
Chuỗi bài: spring boot java 29 dòng · Cập nhật 2026-02-03

DemoApplication.java

spring_boot/code/beginner/src/main/java/com/example/demo/DemoApplication.java

package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * Main entry point for the Spring Boot beginner demo application.
 * <p>
 * {@code @SpringBootApplication} is a convenience annotation that combines:
 * <ul>
 *   <li>{@code @SpringBootConfiguration} — marks this class as a configuration source (like {@code @Configuration})</li>
 *   <li>{@code @EnableAutoConfiguration} — enables Spring Boot's auto-configuration (e.g. embedded Tomcat, default MVC setup)</li>
 *   <li>{@code @ComponentScan} — scans this package and sub-packages for {@code @Component}, {@code @Service}, {@code @Controller}, etc.</li>
 * </ul>
 * The class that bears this annotation is both the application entry point and the root of component scanning.
 */
@SpringBootApplication
public class DemoApplication {

    /**
     * Starts the Spring Application Context and embedded web server.
     * Spring creates beans, wires dependencies, and listens on the configured port (default 8080).
     *
     * @param args command-line arguments (can override properties, e.g. --server.port=9090)
     */
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

Bài viết liên quan

spring boot java Cập nhật 2026-02-03

DemoApplication.java

DemoApplication.java — java source code from the spring boot learning materials (spring_boot/code/advanced/src/main/java/com/example/demo/DemoApplication.java).

Đọc bài viết →
spring boot java Cập nhật 2026-02-03

CustomHealthIndicator.java

CustomHealthIndicator.java — java source code from the spring boot learning materials (spring_boot/code/advanced/src/main/java/com/example/demo/actuator/CustomHealthIndicator.java).

Đọc bài viết →
spring boot java Cập nhật 2026-02-03

SecurityConfig.java

SecurityConfig.java — java source code from the spring boot learning materials (spring_boot/code/advanced/src/main/java/com/example/demo/config/SecurityConfig.java).

Đọc bài viết →
spring boot java Cập nhật 2026-02-03

ProductController.java

ProductController.java — java source code from the spring boot learning materials (spring_boot/code/advanced/src/main/java/com/example/demo/controller/ProductController.java).

Đọc bài viết →
spring boot java Cập nhật 2026-02-03

PublicController.java

PublicController.java — java source code from the spring boot learning materials (spring_boot/code/advanced/src/main/java/com/example/demo/controller/PublicController.java).

Đọc bài viết →
spring boot java Cập nhật 2026-02-03

ProductCreateRequest.java

ProductCreateRequest.java — java source code from the spring boot learning materials (spring_boot/code/advanced/src/main/java/com/example/demo/dto/ProductCreateRequest.java).

Đọc bài viết →