SpringBoot으로 웹 출시까지 #1

springboot logo

1. 환경설정

1 chocolatey 다운로드

JAVA를 다운받기 위해 JAVA 관리 도구로 chocolatey를 다운받는다.

chocolatey로 다운 받으면 따로 환경설정을 할 필요가 없어 간편하게 관리 할 수 있다.

 

https://chocolatey.org/install

에 들어가서 명령어를 복사한다.

 

2023.02.21 기준 명령어는 다음과 같다.

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString(‘https://community.chocolatey.org/install.ps1’))

 

 

– powershell을 “관리자 권한“으로 열어 복사한 명령어를 입력한다.

– 입력한 명령어대로 설치가 잘 되고 있는지 확인한다.

 

 

– 명령어 입력 후 cmd를 “관리자 권한“으로 실행한다.

– “choco -version”을 입력해 설치를 확인한다.

 

 

– 강의와 choco 버전이 다른 것은 문제가 되지 않는다.

– 설치가 되지 않았다면 높은 확률로 관리자 권한으로 열지 않은 것이다.

– 빨간 오류로 당황스러워 여러 시도를 했는데 단순히 관리자 권한으로 열어서 덮어 쓰는 것이 정답이었다.

2 openjdk 설치

– https://community.chocolatey.org/packages?q=openjdk+8 에서

“choco install openjdk8” 명령어를 복사한다.

– cmd 또는 powershell을 “관리자모드”로 열어서 명령어를 입력한다.

설치 도중 긴 말이 나온다면 설치를 허락하겠다는 yes all의 의미로 a를 입력한다.

 

혹시 이전에 자바를 다운받으셨고, 환경설정을 완료하셨다면 제어판 자바 환경설정을 삭제하시는 것을 권장드린다.

choco가 자동으로 환경설정을 해주기 때문에 충돌의 우려가 있다.

3 maven 설치

 https://community.chocolatey.org/packages?q=maven 에서

“choco install maven” 명령어를 복사한다.

– cmd 또는 powershell을 “관리자모드”로 열어서 명령어를 입력한다.

설치 도중 긴 말이 나온다면 설치를 허락하겠다는 yes all의 의미로 a를 입력한다.

 

동영상과 메이븐의 버전이 다르더라도 문제가 없다.

4 IntelliJ 다운로드

https://www.jetbrains.com/ko-kr/idea/download/#section=windows

community edition을 다운받아 설치한다.

5 IntelliJ 설정 및 myjava 만들어 실행 확인하기

동영상 보고 따라하기

public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}

6 myrest 만들어서 restful web 동작 확인

동영상 보고 따라하기

https://start.spring.io/

 

project : maven

springboot :  최대한 낮은 버전 / SNAPSHOT X로 선택

group :  com.godcoder

artifact, name : myrest

java: 8

dependencies : Spring Web

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
package com.godcoder.myrest;

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;
}

}
package com.godcoder.myrest;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.atomic.AtomicLong;

@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));
}
}

http://localhost:8080/greeting

*오류 방지

– 만들어진 maven 프로젝트를 열었을 때

com.godcoder.myrest 로 표시되지 되지 않는다면 파일을 잘못열었거나 이전에 설정을 잘못하신겁니다.

설정을 잘못했을리가 없으시다면 파일을 삭제하고 다시 다운받아 여시는 것을 추천합니다.


– 파일을 추가하실 때 바로 java 클래스 추가가 뜨지 않거나

– 클래스 이름 옆 표시가 파란색이 아니라면 오류가 발생한 것입니다.

오류 코드를 보고 수정이 필요합니다.

– maven 프로젝트를 실행하는 방법은

두 개의 초록색 세모를 누르시면 됩니다.

위의 세모를 누르면 자동으로 실행됩니다.

혹시 오류가 발생했다면 잠시 쉬었다가 재실행 시키시는 것을 추천드립니다.


“Web server failed to start. Port 8080 was already in use.” 가 발생하셨다면 인텔리제이를 껐다가 다시 실행시키시면 바로 해결됩니다.

“SpringBoot으로 웹 출시까지 #1”의 427개의 댓글

  1. Stumbled upon this gem while browsing through player recommendations and I am really glad I gave it a try. The game library keeps updating with fresh titles and the betting limits suit both casual players and high rollers perfectly. Registration took less than a minute and everything just works tbajee38

  2. I have booked my weekend getaway through this amazing travel service and the whole process was seamless. The beds offered are incredibly comfortable and the room selection matches every budget perfectly. I love how transparent they are about pricing with no hidden fees. You should definitely book your next stay through tk1971bed

  3. Grabbing the app through this link made my mobile experience so much smoother. The app runs like butter on my Android device and I never experience any lag during live sessions. Customer service is always one tap away whenever I need a quick answer. I am genuinely impressed by how lightweight yet powerful it feels. descargarbetcrisandroid

  4. I have tested plenty of online casinos and this one definitely keeps it real. The games load fast and the interface is clean without unnecessary clutter. I appreciate how they keep things straightforward and avoid confusing pop ups. My friends and I actually met here and we keep coming back for the good times and fair play. gurucasino

  5. I have tried dozens of platforms but this one keeps me coming back for the sheer quality of service. The live dealer tables feel incredibly authentic and the chat feature makes me feel connected to the action. Deposits and cashouts are handled with a smile every single time. Trust me when I say you will fall in love with this place hb88comvn

  6. [4862]2222bet অফিসিয়াল লগইন | সেরা ক্যাসিনো বোনাস ও অ্যাপ ডাউনলোড,2222bet-এ যোগ দিয়ে সেরা অনলাইন ক্যাসিনো বোনাস বুঝে নিন। বিকাশ দিয়ে দ্রুত ডিপোজিট এবং সহজ নিয়ম মেনে স্লট গেম খেলুন। আজই অ্যাপ ডাউনলোড করে শুরু করুন। visit: 2222bet

댓글 달기

이메일 주소는 공개되지 않습니다.