1 개요[ | ]
- mvnw 프로젝트 jar 패키지 빌드
- STS 메이븐 프로젝트 CMD 컴파일
- 스프링 스타터 프로젝트 HelloWorld에 이어서...
2 mvnw 실행 확인[ | ]
- 만약 아래와 같이 나온다면 JAVA_HOME 환경변수가 설정되지 않은 것이다.
doscon
Copy
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.
- 윈도우 JAVA_HOME 설정을 하고나서 다해 mvnw를 실행해보자.
doscon
Copy
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 폴더가 남아 있다.
doscon
Copy
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을 실행하자.
doscon
Copy
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 폴더가 사라졌다.
doscon
Copy
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 옵션을 주어 테스트를 생략하였다.
doscon
Copy
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 실행 확인[ | ]
doscon
Copy
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 같이 보기[ | ]
편집자 Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.