사용자 도구

사이트 도구


wiki:javascript:react:springboot_react

문서의 이전 판입니다!


SpringBoot + React

스프링부트 프로젝트와 리액트 프로젝트를 각각 생성하여 개발환경 구축하기.


[스프링부트] 데이터로 사용할 객체 생성 후, 리액트에서 요청 받을 컨트롤러 설정
@Getter
public static class User
{
	int id;
	String username;
	String passwd;
	String email;
 
	public User(int id, String username, String passwd, String email)
	{
		this.id = id;
		this.username = username;
		this.passwd = passwd;
		this.email = email;
	}
}
@RestController
public class HiReactController
{	
	// 리액트로부터 요청받을 주소로 매핑
	@PostMapping("/api/users")
	public User user()
	{
		System.out.println("::: HiReactController IN :::");
		User user = new User(1, "eleven", "1234", "jskim@repia.com");
 
		return user;
	}
 
}


[리액트] 부트와 통신하기 위해 proxy와 axios 라이브러리 설치하기
PS ~\react-app> npm install http-proxy-middleware
PS ~\react-app> npm install axios

Ref

/volume1/web/dokuwiki/data/attic/wiki/javascript/react/springboot_react.1623916480.txt.gz · 마지막으로 수정됨: 2022/03/10 19:52 (바깥 편집)