S SmartDocs
시리즈: spring boot java 24 줄 · 업데이트 2026-02-03

GreetingService.java

spring_boot/code/beginner/src/main/java/com/example/demo/service/GreetingService.java

package com.example.demo.service;

import org.springframework.stereotype.Service;

/**
 * Service that generates greeting messages.
 * <p>
 * {@code @Service} is a stereotype of {@code @Component}; Spring registers this class as a bean
 * and injects it wherever needed (e.g. into {@link com.example.demo.controller.HelloController}).
 * Business logic that does not handle HTTP directly belongs in a service layer.
 */
@Service
public class GreetingService {

    /**
     * Builds a greeting string for the given name.
     *
     * @param name the name to include in the greeting (e.g. "Student")
     * @return greeting in the form "Hello, &lt;name&gt;!"
     */
    public String greet(String name) {
        return "Hello, " + name + "!";
    }
}

관련 글

spring boot java 업데이트 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).

글 읽기 →
spring boot java 업데이트 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).

글 읽기 →
spring boot java 업데이트 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).

글 읽기 →
spring boot java 업데이트 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).

글 읽기 →
spring boot java 업데이트 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).

글 읽기 →
spring boot java 업데이트 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).

글 읽기 →