- Member class 생성

package com.cos.blog.test;

public class Member {

	private int id;
	private String username;
	private String password;
	private String email;
	
	public Member(int id, String username, String password, String email) {
		this.id = id;
		this.username = username;
		this.password = password;
		this.email = email;
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
}

Java에서 변수는 Private로 선언해야합니다. 또한 이러한 변수들에 대한 값을 가져오고, 변경하려면 위와같이 getter, setter를 통해 접근해야 합니다.

 

- GET

- POST

  - FORM 방식

@PostMapping("/http/post")
public String postTest(Member m) {
	return "post 요청: " + m.getId() + ", " + m.getUsername() +", " + m.getPassword() +", "+ m.getEmail();
}

  - TEXT 방식

@PostMapping("/http/post")
public String postTest(@RequestBody String text) {
	return "post 요청: " + text;
}

@RequestBody 어노테이션을 선언해줘야합니다.

  - JSON 방식

@PostMapping("/http/post")
public String postTest(@RequestBody Member m) {
	return "post 요청: " + m.getId() + ", " + m.getUsername() +", " + m.getPassword() +", "+ m.getEmail();
}

 

위와같이 queryString, Member객체에 보내는 데이터들이 매핑되는데 이러한 역할을 스프링부트의 MessageConverter가 해준다.

 

 

 

강의 주소 : https://youtu.be/Fd5Rhz0j8QQ

- Controller를 생성합니다.

package com.cos.blog.test;

import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RestController;

// 사용자가 요청 -> 응답(HTML 파일)
// @Controller

// 사용자가 요청 -> 응답(Data)
@RestController
public class HttpControllerTest {

	// http://localhost:8080/http/get
	@GetMapping("/http/get")
	public String getTest() {
		return "get 요청" ;
	}
	
	// http://localhost:8080/http/post
	@PostMapping("/http/post")
	public String postTest() {
		return "post 요청";
	}
	
	// http://localhost:8080/http/put
	@PutMapping("/http/put")
	public String putTest() {
		return "put 요청";
	}
	
	// http://localhost:8080/http/delete
	@DeleteMapping("/http/delete")
	public String deleteTest() {
		return "delete  요청";
	}
}

get 요청
post 요청
put 요청
delete 요청

* 브라우저에서는 get요청만 보낼 수 있습니다. post, put, delete 요청시 405에러가 발생합니다.

 

 

 

강의 주소 : https://youtu.be/BNiDNAWZn-E

Header : Data에 대한 설명을 담고 있습니다.

Body : Data를 담고 있습니다.

 

Http 통신

 

- 패킷 스위칭

 

- 서킷 스위칭

 

 

- MIME 타입

 

https://developer.mozilla.org/ko/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types

 

MIME 타입의 전체 목록 - HTTP | MDN

다음은 일반적인 확장자로 정렬된, 문서 타입과 관련된 MIME 타입의 포괄적인 목록입니다.

developer.mozilla.org

 

 

 

강의 주소 : https://youtu.be/NVjnu4xBdpw

채팅과 같은 서비스에서는 stateful방식을 이용합니다.

채팅과 같이 계속 연결되어야 하는 경우에는 위와 같은 방식으로 연결

 

 

HTTP통신의 경우는 위와같은 방식의 연결을 사용하지 않습니다.

HTTP에서는 stateless 방식을 이용합니다.

 

 

 

강의 주소 : https://youtu.be/fLpmG5tIg1c

1. Postman 설치

https://www.postman.com/downloads/

 

Download Postman | Get Started for Free

Try Postman for free! Join 20 million developers who rely on Postman, the collaboration platform for API development. Create better APIs—faster.

www.postman.com

 

2. HTTP1.1

- get : 데이터를 줘 / Select

- post : 데이터를 추가해줘 / Insert

- put : 데이터를 수정해줘 / Update

- delete : 데이터를 삭제해줘 / Delete

 

 

 

강의 주소 : https://youtu.be/6lSMCAq-fYg

 

git의 3가지 영역 : 작업 영역, 인덱스, 헤드로 나뉩니다.

 

 

강의 주소 : https://youtu.be/pkR_ZeMjWGo

멋진 노을을 사진을 찍어 보관하는 것과 같이 소스코드를 사진을 찍어 보관하는 것(스냅샷)

 

강의 주소 : https://youtu.be/9Nk1a6UMAqo

1. github 회원가입

https://github.com/

 

GitHub: Where the world builds software

GitHub is where over 83 million developers shape the future of software, together. Contribute to the open source community, manage your Git repositories, review code like a pro, track bugs and feat...

github.com

 

2. git 설치

https://git-scm.com/downloads

 

Git - Downloads

Downloads macOS Windows Linux/Unix Older releases are available and the Git source repository is on GitHub. GUI Clients Git comes with built-in GUI tools (git-gui, gitk), but there are several third-party tools for users looking for a platform-specific exp

git-scm.com

 

3. 내 프로젝트 git 연동

프로젝트 경로로 이동하여 Git Bash Here를 클릭

 

아래 코드를 순차적으로 입력합니다.

이대 주소에는 github에서 신규 repository를 생성 후 해당 주소를 붙여줍니다.

git init
git add .
git commit -m "환경세팅완료 v1"
git remote add origin 주소
git push origin master

 

 

강의 주소 : https://youtu.be/O13vCHjKKuk

- 5강의 마지막 MySQL 연결에 대한 강의

 

필자는 application.properties 였던 파일을 application.yml 파일로 변경하고 아래 강의를 따라했습니다.

 

강의 주소 : https://youtu.be/G6fgEiI_pEA

- MySQL 한글 설정 및 연결


아래 주소를 참조

https://getinthere.tistory.com/17

 

스프링부트 with JPA 블로그 3강 - MySQL 한글 설정 및 연결

1. MySQL 한글 설정 my.ini 파일 MySQL 재시작 [client] default-character-set=utf8 [mysql] default-character-set=utf8 [mysqld] collation-server = utf8_unicode_ci init-connect='SET NAMES utf8' init_conn..

getinthere.tistory.com

 

 

강의 주소 : https://youtu.be/GuHhQP0897s

+ Recent posts