java : 11.0.15.1
spring boot : 2.7.4
nodejs : 16.17.1
spring boot 프로젝트 생성
https://dev.to/yesjin/visual-studio-code-spring-boot-2022-11-16-45l3
cd src/main
npx create-react-app frontend # npx create-reeact {프로젝트명}
cd src/main/{프로젝트명}
npm install http-proxy-middleware --save
프론트엔드 - src/main/{프로젝트명}/package.json
"proxy": "http://localhost:8080"
백엔드 - build.gradle
def webappDir = "$projectDir/src/main/frontend"
sourceSets {
main {
resources {
srcDirs = ["$webappDir/build", "$projectDir/src/main/resources"]
}
}
}
processResources {
dependsOn "copyWebApp"
}
task copyWebApp(type: Copy) {
dependsOn "buildReact"
from "$webappDir/build"
into "$projectDir/src/main/resources/static"
}
task buildReact(type: Exec) {
dependsOn "installReact"
workingDir "$webappDir"
inputs.dir "$webappDir"
group = BasePlugin.BUILD_GROUP
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
commandLine "npm.cmd", "run-script", "build"
} else {
commandLine "npm", "run-script", "build"
}
}
task installReact(type: Exec) {
workingDir "$webappDir"
inputs.dir "$webappDir"
group = BasePlugin.BUILD_GROUP
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
commandLine "npm.cmd", "audit", "fix"
commandLine 'npm.cmd', 'install'
} else {
commandLine "npm", "audit", "fix"
commandLine 'npm', 'install'
}
}