※ 이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다.
윈도우에서 IDE 없이 명령프롬프트(cmd)로 프로젝트 빌드하고 실행하는 방법
<요약>
1. 프로젝트 루트 폴더로 이동
2. gradlew.bat
3. gradlew build
4. cd ./build/libs
5. java -jar 파일명
C:\>cd Project
C:\Project>gradlew.bat
C:\Project> gradlew build
C:\Project> cd ./build/libs
C:\Project\build\libs>java -jar Project-0.0.1-SNAPSHOT.war
1. 프로젝트가 있는 폴더로 이동
C:\Project>dir
C:\Project 디렉터리
2024-04-28 오전 12:53 <DIR> .
2024-04-28 오전 12:53 <DIR> ..
2024-04-28 오전 12:52 444 .gitignore
2024-04-28 오전 12:52 595 build.gradle
2024-04-28 오전 12:53 <DIR> gradle
2024-04-28 오전 12:52 8,692 gradlew
2024-04-28 오전 12:52 2,918 gradlew.bat
2024-04-28 오전 12:52 1,220 HELP.md
2024-04-28 오전 12:52 29 settings.gradle
2024-04-28 오전 12:53 <DIR> src
6개 파일 13,898 바이트
4개 디렉터리 166,615,048,192 바이트 남음
2. gradlew.bat 실행
C:\Project>gradlew.bat
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
> Task :help
Welcome to Gradle 8.7.
To run a build, run gradlew <task> ...
To see a list of available tasks, run gradlew tasks
To see more detail about a task, run gradlew help --task <task>
To see a list of command-line options, run gradlew --help
For more detail on using Gradle, see https://docs.gradle.org/8.7/userguide/command_line_interface.html
For troubleshooting, visit https://help.gradle.org
BUILD SUCCESSFUL in 8s
1 actionable task: 1 executed
3. gradlew build 실행
- build 폴더가 생성됨
C:\Project>gradlew build
Java HotSpot(TM) 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.7/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD SUCCESSFUL in 9s
7 actionable tasks: 7 executed
4. ./build/libs 폴더로 이동
C:\Project\build\libs>dir
C:\Project\build\libs 디렉터리
2024-04-28 오전 01:03 <DIR> .
2024-04-28 오전 01:03 <DIR> ..
2024-04-28 오전 01:03 15,237,160 Project-0.0.1-SNAPSHOT-plain.war
2024-04-28 오전 01:03 21,316,505 Project-0.0.1-SNAPSHOT.war
2개 파일 36,553,665 바이트
2개 디렉터리 166,541,643,776 바이트 남음
5. jar 또는 war 실행
C:\Project\build\libs>java -jar Project-0.0.1-SNAPSHOT.war
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.2.5)
2024-04-28T01:10:55.042+09:00 INFO 24328 --- [Project] [ main] Test.Project.ProjectApplication : Starting ProjectApplication v0.0.1-SNAPSHOT using Java 17.0.2 with PID 24328 (C:\Project\build\libs\Project-0.0.1-SNAPSHOT.war started by PC in C:\Project\build\libs)
2024-04-28T01:10:55.056+09:00 INFO 24328 --- [Project] [ main] Test.Project.ProjectApplication : No active profile set, falling back to 1 default profile: "default"
2024-04-28T01:10:56.047+09:00 INFO 24328 --- [Project] [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port 8080 (http)
2024-04-28T01:10:56.058+09:00 INFO 24328 --- [Project] [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2024-04-28T01:10:56.058+09:00 INFO 24328 --- [Project] [ main] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.20]
2024-04-28T01:10:56.129+09:00 INFO 24328 --- [Project] [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2024-04-28T01:10:56.131+09:00 INFO 24328 --- [Project] [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1003 ms
2024-04-28T01:10:56.446+09:00 INFO 24328 --- [Project] [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port 8080 (http) with context path ''
2024-04-28T01:10:56.460+09:00 INFO 24328 --- [Project] [ main] Test.Project.ProjectApplication : Started ProjectApplication in 1.828 seconds (process running for 2.213)
5번을 실행 할때 아래와 같이 에러가 발생한다면 링크 참조
https://mousepotato.tistory.com/130
Description:
Web server failed to start. Port 8080 was already in use.
Action:
Identify and stop the process that's listening on port 8080 or configure this application to listen on another port.
gradlew clean
- 프로젝트가 꼬인거 같을때 clean을 한번 해주고 다시 빌드(gradlew build) 해주면 보통은 풀림
- gradlew clean을 하면 build 폴더가 사라짐
C:\Project>dir
C:\Project 디렉터리
2024-04-28 오전 01:03 <DIR> .
2024-04-28 오전 01:03 <DIR> ..
2024-04-28 오전 12:52 444 .gitignore
2024-04-28 오전 01:03 <DIR> .gradle
2024-04-28 오전 01:03 <DIR> build
2024-04-28 오전 12:52 595 build.gradle
2024-04-28 오전 12:53 <DIR> gradle
2024-04-28 오전 12:52 8,692 gradlew
2024-04-28 오전 12:52 2,918 gradlew.bat
2024-04-28 오전 12:52 1,220 HELP.md
2024-04-28 오전 12:52 29 settings.gradle
2024-04-28 오전 12:53 <DIR> src
6개 파일 13,898 바이트
6개 디렉터리 164,890,189,824 바이트 남음
C:\Project>gradlew clean
BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed
C:\Project>dir
C:\Project 디렉터리
2024-04-28 오전 02:00 <DIR> .
2024-04-28 오전 02:00 <DIR> ..
2024-04-28 오전 12:52 444 .gitignore
2024-04-28 오전 01:03 <DIR> .gradle
2024-04-28 오전 12:52 595 build.gradle
2024-04-28 오전 12:53 <DIR> gradle
2024-04-28 오전 12:52 8,692 gradlew
2024-04-28 오전 12:52 2,918 gradlew.bat
2024-04-28 오전 12:52 1,220 HELP.md
2024-04-28 오전 12:52 29 settings.gradle
2024-04-28 오전 12:53 <DIR> src
6개 파일 13,898 바이트
5개 디렉터리 164,924,559,360 바이트 남음
'기타' 카테고리의 다른 글
[git] vscode git 초기 셋팅, commit, pull (0) | 2024.11.10 |
---|---|
[VirtualBox] 버추얼박스 해상도 조절(Win10 FHD) (0) | 2024.11.09 |
[Spring] Web server failed to start. Port 8080 was already in use. (windows) (0) | 2024.04.27 |
[VSCode] git logout (0) | 2024.04.07 |
[VSCode] git 프로젝트 내려받기 (0) | 2024.04.07 |