사용자 도구

사이트 도구


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 D:\eclipse_repository\demoReact\react-app> npm install axios

Ref

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