STS 메이븐 프로젝트 jar 패키지 빌드

Jmnote (토론 | 기여)님의 2017년 7월 14일 (금) 14:45 판

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 같이 보기

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