Boot-React 배포 -10/02

Jo-Jun_yeong·2024년 10월 2일

고정적인 배포 코드

sourceSets {
main {
resources { srcDirs = ["$빌드가/될/위치"]
}
}
}

def frontendDir = "$projectDir/src/main/frontend"

sourceSets {
	main {
		resources { srcDirs = ["$projectDir/src/main/resources"]
		}
	}
}

processResources { dependsOn "copyReactBuildFiles" }

task installReact(type: Exec) {
	workingDir "$frontendDir"
	inputs.dir "$frontendDir"
	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'
	}
}

task buildReact(type: Exec) {
	dependsOn "installReact"
	workingDir "$frontendDir"
	inputs.dir "$frontendDir"
	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 copyReactBuildFiles(type: Copy) {
	dependsOn "buildReact"
	from "$frontendDir/build"
	into "$projectDir/src/main/resources/static"
}

서버를 모두 종료시킨 후


gradlew build

cd/build/libs폴더로 간 후
java -jar SpringReact-0.0.1-SNAPSHOT.jar

굿
SpringReact-0.0.1-SNAPSHOT.jar 파일을 가져가서 실행시킨다.

한글 꺠지지않게 하기


springReact폴더로 와서

기존 빌드 지우고 다시 빌드
gradlew clean build

profile
5_hero_like

0개의 댓글