Spring Boot Hello World in Eclipse

reference

I tried it by referring to "Spring Quickstart Guide" on the official page of Spring. https://spring.io/quickstart

environment

Create Spring project

Generate to your liking on the official Project Generation Page. image.png

Press the GENERATE button to download the project as a zip.

Import project in eclipse

Import Gradle project

image.png

Specify the downloaded folder

image.png

Imported

image.png

If there is no problem, the necessary libraries will be downloaded and the build will be done without permission. image.png

Run

image.png

When Spring Boot starts, it looks like this image.png

Go to http: // localhost: 8080 /. I get an error because I haven't written the routing process yet. image.png

Create a routing process

Add routing to the main class in your project. image.png

Get request parameters with GET request

package com.pakhuncho.hello;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
public class HelloApplication {

	public static void main(String[] args) {
		SpringApplication.run(HelloApplication.class, args);
	}

	@GetMapping("/hello")
	public String hello(@RequestParam(value = "name", defaultValue = "World") String name) {
		return String.format("Hello %s!", name);
	}
}

Relocate the modified application. image.png

Access at http: // localhost: 8080 / hello. image.png

Access with http: // localhost: 8080 / hello? Name = pakhuncho. image.png

http: // localhost: 8080 / hello? name = Access with Pakupaku image.png

Get path parameters

package com.pakhuncho.hello;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
public class HelloApplication {

	public static void main(String[] args) {
		SpringApplication.run(HelloApplication.class, args);
	}

	@RequestMapping("/hello/{name}")
	public String hello(@PathVariable String name) {
		return String.format("Hello %s!", name);
	}
}

Access with http: // localhost: 8080 / hello / Pakupaku image.png

Recommended Posts

Spring Boot Hello World in Eclipse
Hello World with Eclipse + Spring Boot + Maven
[Practice! ] Display Hello World in Spring Boot
Hello World with Spring Boot
Hello World with Spring Boot!
Hello World with Spring Boot
Spring Boot application development in Eclipse
Until "Hello World" with Spring Boot
Hello World in java in eclipse now
(Intellij) Hello World with Spring Boot
(IntelliJ + gradle) Hello World with Spring Boot
"Hello World" in Java
Hello world in node.js
Hello World in Java
Compare Hello, world! In Spring Boot with Java, Kotlin and Groovy
Hello world! With Spring Boot (Marven + text editor)
[Java] Hello World with Java 14 x Spring Boot 2.3 x JUnit 5 ~
Set context-param in Spring Boot
Spring Boot 2 multi-project in Gradle
Major changes in Spring Boot 1.5
NoHttpResponseException in Spring Boot + WireMock
Hello World (REST API) with Apache Camel + Spring Boot 2
Until you start development with Spring Boot in eclipse 1
Until you start development with Spring Boot in eclipse 2
Hello World comparison between Spark Framework and Spring Boot
Hello World (console app) with Apache Camel + Spring Boot 2
Write test code in Spring Boot
Implement REST API in Spring Boot
What is @Autowired in Spring boot?
Implement Spring Boot application in Gradle
hello, world in Vanilla Java-EHW2018 "MVP"
"Hello world" for ImageJ with Eclipse
Thymeleaf usage notes in Spring Boot
Hello world in Java and Gradle
Unknown error in line 1 of pom.xml when using Spring Boot in Eclipse
Launch (old) Spring Boot project in IntelliJ
Build Spring Boot + Docker image in Gradle
Static file access priority in Spring boot
Hello, World! In the bootstrap loader area
How to include Spring Tool in Eclipse 4.6.3?
Output Spring Boot log in json format
Local file download memorandum in Spring Boot
Create Java Spring Boot project in IntelliJ
Loosen Thymeleaf syntax checking in Spring Boot
"Hello, World!" With Kotlin + CLI in 5 minutes
Use DynamoDB query method in Spring Boot
How Spring Security works with Hello World
DI SessionScope Bean in Spring Boot 2 Filter
Maven configuration problem in Spring pom.xml in Eclipse
Add spring boot and gradle to eclipse
Change session timeout time in Spring Boot
Read "Hello world"
Challenge Spring Boot
Spring Boot2 Web application development with Visual Studio Code Hello World creation
MVC in Eclipse.
Java, Hello, world!
Java Hello World
Spring Boot Form
Spring Boot Memorandum
gae + spring boot
"Teacher, I want to implement a login function in Spring" ① Hello World