각진 세상에 둥근 춤을 추자
[Spring Boot] MAC 스프링부트 설치 및 개발환경 구축 본문
(1) 아래 홈페이지에서 STS4 다운받기
Spring Tools 4 is the next generation of Spring tooling
Largely rebuilt from scratch, Spring Tools 4 provides world-class support for developing Spring-based enterprise applications, whether you prefer Eclipse, Visual Studio Code, or Theia IDE.
spring.io



(2) Help - Eclipse MarketPlace - 'Eclipse Web Developr Tools 3.28' 설치


[File] - [New] - [Spring Starter Project]

- Name: 프로젝트명
- Type: Gradle - Groovy
- Packaging: Jar
- Java Version: 11
- Language: Java
- Group, Package: kr.co.패키지명

- Spring Boot Version: 2.7.7
- Selected: Spring boot DevTools, Lombok, Thymeleaf, Spring Web

Do you wish to enable additional Java sources reconciling to get Spring specific validations and suggestions? YES

프로젝트 실행하기 - 프로젝트 마우스 우클릭 - Run As - 5 Spring Boot App

Spring 실행

http://localhost:8080 접속

(1) 프로젝트 - src/main/java - kr.co.ch06 - Ch06Application.java
package kr.co.ch06;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@SpringBootApplication
public class Ch06Application {
public static void main(String[] args) {
SpringApplication.run(Ch06Application.class, args);
}
}
(2) 프로젝트 - src/main/java - kr.co.ch06.controller 생성 - MainController.java 생성
package kr.co.ch06.controller;
import java.util.ArrayList;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import kr.co.ch06.vo.UserVO;
@Controller
public class MainController {
@GetMapping(value = {"/", "/index"})
public String index() {
return "/index";
}
@GetMapping("/hello")
public String hello() {
return "/hello";
}
@GetMapping("/welcome")
public String welcome() {
return "/welcome";
}
@GetMapping("/greeting")
public String greeting() {
return "/greeting";
}
}
(3) 프로젝트 - src/main/resources - templates - index.html 생성
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>index</title>
</head>
<body>
<h3>스프링부트 실습</h3>
<a href="/hello">hello</a>
<a href="/welcome">welcome</a>
<a href="/greeting">greeting</a>
</body>
</html>
(4) 프로젝트 - src/main/resources - templates - hello.html, welcome.html, greeting.html 생성
hello.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>hello</title>
</head>
<body>
<h3>Hello Spring Boot</h3>
<a href="/">메인</a>
</body>
</html>
welcome.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>welcome</title>
</head>
<body>
<h3>Welcome Spring Boot</h3>
<a href="/">메인</a>
</body>
</html>
greeting.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>greeting</title>
</head>
<body>
<h3>Greeting Spring Boot</h3>
<a href="/">메인</a>
</body>
</html>
(5) 프로젝트 마우스 우클릭 - Run As - 5 Spring Boot App + localhost:8080 접속




'Spring' 카테고리의 다른 글
[Spring Boot] JPA 사용 - 간단 회원 정보 입력, 목록, 수정, 삭제 (0) | 2023.01.11 |
---|---|
[Spring Boot] 스프링부트 DB 연동 + Lombok 설치 +간단 회원 정보 입력, 목록, 수정 (1) | 2023.01.10 |
[Spring] MyBatis (간단) 회원 정보 입력, 목록, 수정, 삭제 (0) | 2023.01.06 |
[Spring] MyBatis 설정 + DB 연결 (0) | 2023.01.05 |
[Spring] 스프링 MVC 회원 정보 입력 결과 출력하기 (0) | 2023.01.05 |