2022. 10. 2. 17:31ㆍ프로젝트/Spring Boot
실습환경
Intellij(인텔리제이), Spring boot
실습하기
Chcolatey 설치하기
https://chocolatey.org/install
Installing Chocolatey
Chocolatey is software management automation for Windows that wraps installers, executables, zips, and scripts into compiled packages. Chocolatey integrates w/SCCM, Puppet, Chef, etc. Chocolatey is trusted by businesses to manage software deployments.
chocolatey.org

복사 버튼을 클릭하여 Powershell에 입력합니다.

Powershell 관리자 권한으로 시작하고, Chocolatery 설치합니다.

choco -version |
OpenJDK + Maven 설치하기
https://community.chocolatey.org/packages?q=openjdk+8
Packages matching openjdk 8
Chocolatey is software management automation for Windows that wraps installers, executables, zips, and scripts into compiled packages. Chocolatey integrates w/SCCM, Puppet, Chef, etc. Chocolatey is trusted by businesses to manage software deployments.
community.chocolatey.org


CMD 창을 관리자 권한으로 실행하고 복사했던 글을 붙여넣습니다.

마찬가지로 CMD 창을 열어 Maven 설치를 합니다.

Maven이 정상 설치되었음을 확인할 수 있습니다.
인텔리제이로 Spring이 정상작동 되는지 확인하기

저번 시간에 설치했던 인텔리제이를 실행한 다음 + 버튼을 클릭하여 프로젝트 생성하고, Java 8버전을 체크한 후 다음(N) 클릭합니다.

Spring Web 클릭 후 생성(c) 클릭합니다.
https://spring.io/guides/gs/rest-service/
Building a RESTful Web Service
this guide is designed to get you productive as quickly as possible and using the latest Spring project releases and techniques as recommended by the Spring team
spring.io
가이드를 따라 폴더를 생성한 후 다음과같이 만듭니다.
- com.example.basic 폴더 안에 Greeting.java 파일

public class Greeting {
private final long id;
private final String content;
public Greeting(long id, String content) {
this.id = id;
this.content = content;
}
public long getId() {
return id;
}
public String getContent() {
return content;
}
}
- com.example.basic 폴더 안에 GreetingController.java 파일
@RestController
public class GreetingController {
private static final String template = "Hello, %s!";
private final AtomicLong counter = new AtomicLong();
@GetMapping("/greeting")
public Greeting greeting(@RequestParam(value = "name", defaultValue = "World") String name) {
return new Greeting(counter.incrementAndGet(), String.format(template, name));
}
}
★ 빨간색이 뜨는 부분은 alt + enter 누른 후 클래스 가져오기를 합니다.
다 작성한 이 후 메인코드에 들어가 실행을 한 후 다음 링크에 접속합니다.
http://localhost:8080/greeting

링크로 접속하면 실행이 정상적임을 확인할 수 있습니다.
참고자료
https://spring.io/guides/gs/rest-service/
Building a RESTful Web Service
this guide is designed to get you productive as quickly as possible and using the latest Spring project releases and techniques as recommended by the Spring team
spring.io
'프로젝트 > Spring Boot' 카테고리의 다른 글
Spring Boot MariaDB 연동하기 (0) | 2022.10.05 |
---|---|
Thymeleaf 이용하여 레이아웃 만들기 (0) | 2022.10.04 |
BootStrap 템플릿으로 간단한 레이아웃 만들기 (0) | 2022.10.04 |
Thymeleaf 기본 (0) | 2022.10.02 |
Spring Boot Thymeleaf 이용하여 간단한 예제 만들기 (0) | 2022.10.02 |