React Spring Boot 빌드설정

Posted by Albert 768Day 3Hour 7Min 34Sec ago [2023-03-14]

Springboot 웹 개발시 프론트 설정


1. React 상 로컬 Spring Boot 경로에 접근 가능하도록 proxy 추가 

package.json

{
  "name": "frontend",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "axios": "^1.3.4",
    "bootstrap": "^5.2.3",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-router-dom": "^6.9.0",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4"
  },
  "proxy": "http://localhost:8888",
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
}


2. root경로에 .env 파일 생성하여주고 빌드시 자동으로 springboot static 하단에 관련 빌드파일이 생성되게 설정

BUILD_PATH='../src/main/resources/static'


참고용 소스 





LIST

Copyright © 2014 visionboy.me All Right Reserved.