
React 애플리케이션을 빌드한 후 생성된 정적 파일들을 Spring 프로젝트의 리소스 디렉토리에 추가하고, Spring 컨트롤러를 통해 React를 Spring 프로젝트에 통합
@Controller
public class DashboardController {
@GetMapping("/dashboard")
public String Dashboard() {
return "dashboard";
}
}
"proxy" : ~,"homepage": "/dashboard",index.html -> dashboard.htmlreturn "dashboard"; 이기 때문에 html 이름 맞춤<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8"/>
<meta translate="no"/>
<meta name="viewport" content="width=device-width,initial-scale=1"/>
<title>Linme Dashboard</title>
<script defer="defer" src="/dashboard/static/js/main.5edadf5e.js">
</script>
</head>
<body>
<div id="root">
</div>
</body>
</html>
dashboard.html 파일
templates/dashboard.htmlreturn "dashboard";static/dashboard (dashboard 폴더 생성)src="/dashboard/static/js/main.5edadf5e.js" 로 되어있는데 경로를 맞춘다.
잘 나오는 것을 볼 수 있다!