"STS 메이븐 프로젝트 jar 패키지 빌드"의 두 판 사이의 차이

잔글 (Jmnote님이 Mvnw 프로젝트 jar 패키지 빌드 문서를 STS 메이븐 프로젝트 jar 패키지 빌드 문서로 이동했습니다)
잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
(다른 사용자 한 명의 중간 판 3개는 보이지 않습니다)
6번째 줄: 6번째 줄:
==mvnw 실행 확인==
==mvnw 실행 확인==
* 만약 아래와 같이 나온다면 JAVA_HOME 환경변수가 설정되지 않은 것이다.
* 만약 아래와 같이 나온다면 JAVA_HOME 환경변수가 설정되지 않은 것이다.
<source lang='doscon'>
<syntaxhighlight lang='doscon'>
D:\workspace-sts\HelloWorld>mvnw
D:\workspace-sts\HelloWorld>mvnw


12번째 줄: 12번째 줄:
Please set the JAVA_HOME variable in your environment to match the
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
location of your Java installation.
</source>
</syntaxhighlight>
* '''[[윈도우 JAVA_HOME 설정]]'''을 하고나서 다해 mvnw를 실행해보자.
* '''[[윈도우 JAVA_HOME 설정]]'''을 하고나서 다해 mvnw를 실행해보자.
<source lang='doscon'>
<syntaxhighlight lang='doscon'>
D:\workspace-sts\HelloWorld>mvnw
D:\workspace-sts\HelloWorld>mvnw
[INFO] Scanning for projects...
[INFO] Scanning for projects...
31번째 줄: 31번째 줄:
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException
</source>
</syntaxhighlight>


==mvnw clean==
==mvnw clean==
* STS(이클립스)에서 Run As --- Spring Boot App 을 실행한 적이 있다면 아래와 같이 target 폴더가 남아 있다.
* STS(이클립스)에서 Run As --- Spring Boot App 을 실행한 적이 있다면 아래와 같이 target 폴더가 남아 있다.
<source lang='doscon'>
<syntaxhighlight lang='doscon'>
D:\workspace-sts\HelloWorld>tree
D:\workspace-sts\HelloWorld>tree
DATA 볼륨에 대한 폴더 경로의 목록입니다.
DATA 볼륨에 대한 폴더 경로의 목록입니다.
64번째 줄: 64번째 줄:
         └─com
         └─com
             └─example
             └─example
</source>
</syntaxhighlight>
* CMD에서 새롭게 컴파일하기 위해 mvnw install을 실행하자.
* CMD에서 새롭게 컴파일하기 위해 mvnw install을 실행하자.
<source lang='doscon'>
<syntaxhighlight lang='doscon'>
D:\workspace-sts\HelloWorld>mvnw clean
D:\workspace-sts\HelloWorld>mvnw clean
[INFO] Scanning for projects...
[INFO] Scanning for projects...
83번째 줄: 83번째 줄:
[INFO] Final Memory: 12M/115M
[INFO] Final Memory: 12M/115M
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
</source>
</syntaxhighlight>
* 다시 tree를 확인해보면 target 폴더가 사라졌다.
* 다시 tree를 확인해보면 target 폴더가 사라졌다.
<source lang='doscon'>
<syntaxhighlight lang='doscon'>
D:\workspace-sts\HelloWorld>tree
D:\workspace-sts\HelloWorld>tree
DATA 볼륨에 대한 폴더 경로의 목록입니다.
DATA 볼륨에 대한 폴더 경로의 목록입니다.
103번째 줄: 103번째 줄:
             └─com
             └─com
                 └─example
                 └─example
</source>
</syntaxhighlight>


==mvnw package==
==mvnw package==
* 여기서는 -DskipTests=true 옵션을 주어 테스트를 생략하였다.
* 여기서는 -DskipTests=true 옵션을 주어 테스트를 생략하였다.
<source lang='doscon'>
<syntaxhighlight lang='doscon'>
D:\workspace-sts\HelloWorld>mvnw package -DskipTests=true
D:\workspace-sts\HelloWorld>mvnw package -DskipTests=true
[INFO] Scanning for projects...
[INFO] Scanning for projects...
144번째 줄: 144번째 줄:
[INFO] Final Memory: 23M/182M
[INFO] Final Memory: 23M/182M
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
</source>
</syntaxhighlight>
:→ [[target\HelloWorld-0.0.1-SNAPSHOT.jar]]으로 패키지가 빌드되었다.
:→ target\HelloWorld-0.0.1-SNAPSHOT.jar 으로 패키지가 빌드되었다.
 
==실행 확인==
<syntaxhighlight lang='doscon'>
D:\workspace-sts\HelloWorld>java -jar target\HelloWorld-0.0.1-SNAPSHOT.jar
 
  .  ____          _            __ _ _
/\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot ::        (v1.5.3.RELEASE)
 
2017-07-14 14:47:37.778  INFO 6920 --- [           main] com.example.HelloWorldApplication        : Starting HelloWorldApplication v0.0.1-SNAPSHOT on ZETAWIKI with PID 6920 (D:\workspace-sts\He
lloWorld\target\HelloWorld-0.0.1-SNAPSHOT.jar started by user2 in D:\workspace-sts\HelloWorld)
2017-07-14 14:47:37.794  INFO 6920 --- [          main] com.example.HelloWorldApplication        : No active profile set, falling back to default profiles: default
2017-07-14 14:47:37.919  INFO 6920 --- [          main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@1698c449: start
up date [Fri Jul 14 14:47:37 KST 2017]; root of context hierarchy
2017-07-14 14:47:39.091  INFO 6920 --- [          main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2017-07-14 14:47:39.122  INFO 6920 --- [          main] com.example.HelloWorldApplication        : Started HelloWorldApplication in 2.047 seconds (JVM running for 2.958)
Hello, World!
2017-07-14 14:47:39.138  INFO 6920 --- [      Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@1698c449: startup
date [Fri Jul 14 14:47:37 KST 2017]; root of context hierarchy
2017-07-14 14:47:39.153  INFO 6920 --- [      Thread-2] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown
</syntaxhighlight>
:→ STS에서 실행한 결과와 동일하게 정상적으로 실행되었다.


==같이 보기==
==같이 보기==
* [[스프링 스타터 프로젝트 HelloWorld]]
* [[스프링 스타터 프로젝트 HelloWorld]]
* [[mvnw.cmd]]
* [[스프링 스타터 프로젝트 HelloWorld jar 파일 내보내기]]


[[분류: STS]]
[[분류: STS]]
[[분류: Maven]]
[[분류: Maven]]

2020년 11월 2일 (월) 02:50 기준 최신판

1 개요[ | ]

mvnw 프로젝트 jar 패키지 빌드
STS 메이븐 프로젝트 CMD 컴파일

2 mvnw 실행 확인[ | ]

  • 만약 아래와 같이 나온다면 JAVA_HOME 환경변수가 설정되지 않은 것이다.
D:\workspace-sts\HelloWorld>mvnw

Error: JAVA_HOME not found in your environment.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
D:\workspace-sts\HelloWorld>mvnw
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.719 s
[INFO] Finished at: 2017-07-14T14:20:33+09:00
[INFO] Final Memory: 12M/115M
[INFO] ------------------------------------------------------------------------
[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException

3 mvnw clean[ | ]

  • STS(이클립스)에서 Run As --- Spring Boot App 을 실행한 적이 있다면 아래와 같이 target 폴더가 남아 있다.
D:\workspace-sts\HelloWorld>tree
DATA 볼륨에 대한 폴더 경로의 목록입니다.
볼륨 일련 번호가 00000010 6D80:24A7입니다.
D:.
├─.mvn
│  └─wrapper
├─.settings
├─src
│  ├─main
│  │  ├─java
│  │  │  └─com
│  │  │      └─example
│  │  └─resources
│  └─test
│      └─java
│          └─com
│              └─example
└─target
    ├─classes
    │  ├─com
    │  │  └─example
    │  └─META-INF
    │      └─maven
    │          └─com.example
    │              └─HelloWorld
    └─test-classes
        └─com
            └─example
  • CMD에서 새롭게 컴파일하기 위해 mvnw install을 실행하자.
D:\workspace-sts\HelloWorld>mvnw clean
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building HelloWorld 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ HelloWorld ---
[INFO] Deleting D:\workspace-sts\HelloWorld\target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.813 s
[INFO] Finished at: 2017-07-14T14:30:23+09:00
[INFO] Final Memory: 12M/115M
[INFO] ------------------------------------------------------------------------
  • 다시 tree를 확인해보면 target 폴더가 사라졌다.
D:\workspace-sts\HelloWorld>tree
DATA 볼륨에 대한 폴더 경로의 목록입니다.
볼륨 일련 번호가 000000FF 6D80:24A7입니다.
D:.
├─.mvn
│  └─wrapper
├─.settings
└─src
    ├─main
    │  ├─java
    │  │  └─com
    │  │      └─example
    │  └─resources
    └─test
        └─java
            └─com
                └─example

4 mvnw package[ | ]

  • 여기서는 -DskipTests=true 옵션을 주어 테스트를 생략하였다.
D:\workspace-sts\HelloWorld>mvnw package -DskipTests=true
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building HelloWorld 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ HelloWorld ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ HelloWorld ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ HelloWorld ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\workspace-sts\HelloWorld\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ HelloWorld ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ HelloWorld ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ HelloWorld ---
[INFO] Building jar: D:\workspace-sts\HelloWorld\target\HelloWorld-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:1.5.3.RELEASE:repackage (default) @ HelloWorld ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.370 s
[INFO] Finished at: 2017-07-14T14:44:16+09:00
[INFO] Final Memory: 23M/182M
[INFO] ------------------------------------------------------------------------
→ target\HelloWorld-0.0.1-SNAPSHOT.jar 으로 패키지가 빌드되었다.

5 실행 확인[ | ]

D:\workspace-sts\HelloWorld>java -jar target\HelloWorld-0.0.1-SNAPSHOT.jar

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.3.RELEASE)

2017-07-14 14:47:37.778  INFO 6920 --- [           main] com.example.HelloWorldApplication        : Starting HelloWorldApplication v0.0.1-SNAPSHOT on ZETAWIKI with PID 6920 (D:\workspace-sts\He
lloWorld\target\HelloWorld-0.0.1-SNAPSHOT.jar started by user2 in D:\workspace-sts\HelloWorld)
2017-07-14 14:47:37.794  INFO 6920 --- [           main] com.example.HelloWorldApplication        : No active profile set, falling back to default profiles: default
2017-07-14 14:47:37.919  INFO 6920 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@1698c449: start
up date [Fri Jul 14 14:47:37 KST 2017]; root of context hierarchy
2017-07-14 14:47:39.091  INFO 6920 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2017-07-14 14:47:39.122  INFO 6920 --- [           main] com.example.HelloWorldApplication        : Started HelloWorldApplication in 2.047 seconds (JVM running for 2.958)
Hello, World!
2017-07-14 14:47:39.138  INFO 6920 --- [       Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@1698c449: startup
date [Fri Jul 14 14:47:37 KST 2017]; root of context hierarchy
2017-07-14 14:47:39.153  INFO 6920 --- [       Thread-2] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown
→ STS에서 실행한 결과와 동일하게 정상적으로 실행되었다.

6 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}