From e51834c899ff20781295410961934eb06239385c Mon Sep 17 00:00:00 2001 From: Kamal Wickramanayake Date: Sat, 16 May 2026 21:18:32 +0530 Subject: Added spring-boot sample applications --- .../main/java/com/example/spring/Application.java | 20 ++++++++++++++++++++ .../com/example/spring/hello/HelloController.java | 19 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 spring-boot/02-structure/src/main/java/com/example/spring/Application.java create mode 100644 spring-boot/02-structure/src/main/java/com/example/spring/hello/HelloController.java (limited to 'spring-boot/02-structure/src/main/java/com/example') diff --git a/spring-boot/02-structure/src/main/java/com/example/spring/Application.java b/spring-boot/02-structure/src/main/java/com/example/spring/Application.java new file mode 100644 index 0000000..c051033 --- /dev/null +++ b/spring-boot/02-structure/src/main/java/com/example/spring/Application.java @@ -0,0 +1,20 @@ +package com.example.spring; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @SpringBootApplication - Indicates a configuration class that declares one or + * more @Bean methods and also triggers + * auto-configuration and component scanning. This is a + * convenience annotation that is equivalent to + * declaring @Configuration, @EnableAutoConfiguration + * and @ComponentScan. + */ +@SpringBootApplication +public class Application { + + public static void main(String[] args) throws Exception { + SpringApplication.run(Application.class, args); + } +} \ No newline at end of file diff --git a/spring-boot/02-structure/src/main/java/com/example/spring/hello/HelloController.java b/spring-boot/02-structure/src/main/java/com/example/spring/hello/HelloController.java new file mode 100644 index 0000000..ad89d9d --- /dev/null +++ b/spring-boot/02-structure/src/main/java/com/example/spring/hello/HelloController.java @@ -0,0 +1,19 @@ +package com.example.spring.hello; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class HelloController { + + @Value("${my.name}") + private String name; + + @RequestMapping("/") + @ResponseBody + String home() { + return "Hello " + name + "!"; + } +} \ No newline at end of file -- cgit v1.2.3