전통적인 스프링 프로젝트는 주로 Tomcat과 같은 웹 컨테이너에 배치 될 수 있습니다. Spring Boot는 애플리케이션을 JAR 패키지로 직접 결합하는 매우 간단한 배포 방법을 제공하며, 제작에서 Java -Jar를 실행하기 만하면됩니다.
이 기사에서는 실행 가능한 JAR 패키지를 만드는 방법과 배포, 실행 및 중지 방법에 대해 설명합니다.
첫 번째 단계에서는 Spring-Boot-Maven-Plugin을 Pom.xml에 추가하고 아래의 종속성 섹션에 추가해야합니다.
<빌드> <플러그인> <플러그인> <groupid> org.springframework.boot </groupid> <artifactid> Spring-Boot-Maven-Plugin </artifactid> </plugin> </plugins> </build>
두 번째 단계는 pom.xml을 저장하고 MVN 패키지 명령을 패키지로 실행하는 것입니다.
LocalHost : Spring-Boot-Tutiorial-Executable-Executable Majunwei $ MVN 패키지 -dmaven.test.skip = true [info] 프로젝트 스캔 ... [경고] [경고] com.majunwei에 대한 효과적인 모델을 구축하는 동안 일부 문제가 발생했습니다. com.majunwei : Spring-Boot-Tutorial-Executable : 0.0.1-snapshot (/users/majunwei/documents/work/spring-boot-tutorial/spring-boot-tutorial-executable/pom.xml) org.springframework.boot : Spring-Boot-starter-Parent, 프로젝트 구조 @ @ 6 열 [경고] [경고] 건물의 안정성을 위협하기 때문에 이러한 문제를 해결하는 것이 좋습니다. [경고] [경고] 이런 이유로 향후 Maven 버전은 더 이상 잘못된 프로젝트를 구축하지 못할 수 있습니다. [정보] [정보]. -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- /user/majunwei/documents/spring-boot-tutiorial/spring-boot-tutorial-excutable/src/main/resources [info] 비기기 자원이 아닌 자원이없는 리소스 레이더/users/majunwei/documents/spring-tutorial/Spring-Boot-Tutorial-Executable/SRC/Main/Resources [Info] --------------------------------- Maven-Compiler-Plugin : 3.1 : 컴파일 (기본 컴파일) @ Spring-Boot-Tutorial-Executable --- [Info] Compile에 아무것도 컴파일 할 필요가 없습니다. 모든 클래스는 최신 상태입니다 [info] [info] --- Maven-Resources-Plugin : 2.6 : testresources (default-testresources) @ spring-bboot-tuticutive-- [info]-[info]-[info. [Info] --- Maven-Compiler-Plugin : 3.1 : TestCompile (Default-TestCompile) @ Spring-Boot-Tutorial-Executable --- [Info] 테스트 소스를 컴파일하지 않음 [info] [info] --- Maven-Surefire-Plugin : 2.18.1 : 2.18.1 : 테스트 (Spring-BBOOT-TUTIONT-executable-)-정보 테스트. [Info] --- Maven-Jar-Plugin : 2.6 : Jar (기본-자르) @ Spring-Boot-Tutorial-Executable --- [Info] [Info] --- Spring-Boot-Maven-Plugin : 1.5.6. Release (기본) @ Spring-Boot-Tutorial-Executable --- [Info] ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
포장 작업을 완료하고 대상 디렉토리에 큰 패키지를 저장합니다. 약 10MB 여야합니다.
로컬 호스트 : 대상 Majunwei $ ls -lhtotal 28232drwxr-xr-x 4 Majunwei 직원 136b 8 4 11:12 Classesdrwxr-xr-x 3 Majunwei 직원 102b 8 4 11:14 생성 된 소스 Drwxr-xr-x 3 Majunwei 직원 102b 8 4 114 Maven-roucdrdr-x 3 maven-roctrdr-x 3 Majunwei 직원 102b. Majunwei Staff 102b 8 4 11:14 Maven-Status-RW-R --- 1 Majunwei 직원 14m 8 4 11:14 Spring-Boot-Tutorial-executable-0.0.1-snapshot.jar-rw-r --- 1 Majunwei 직원 3.2k 8 11:14 Spring-Boot-Tutorial-Executable-0.0.1-SnapShot.jar.OriginalDrwxr-XR-X 3 Majunwei 직원 102b 8 4 11:12 테스트 클래스
이 패키지에는 종속 JAR 패키지, 클래스 및 기타 정보가 포함되어 있습니다. 이 JAR 패키지의 내용을주의 깊게 보려면 JAR TVF 명령을 사용하거나 압축을 풀어 읽을 수 있습니다.
$ JAR TVF Spring-Boot-Tutorial-Executable-0.0.1-snapshot.jar
대상 디렉토리에는 myProject-0.0.1-snapshot.jar.original에 대한 매우 작은 파일도 있습니다. 스프링 부트가 포장되기 전에 Maven이 만든 원래 JAR 파일입니다.
세 번째 단계는 Java -jar 명령을 사용하여 응용 프로그램을 실행하는 것입니다.
LocalHost : Target Majunwei $ Java -Jar Spring-Boot-Tutiorial-Executable-0.0.1-snapshot.jar. ____ __ _ /// / ___'_ __ __ _ _ _ (_) _ __ __ __ / / / / () / ___ | .__ | | _ | | _ | | =============== | _ | ================================= ____/=/_/_/:: (v1.5.6. Release) 2017-08-04 12 : 05 : 58.917 정보 909-- [Main] OSBTUTUCATION. v0.0.1-SNAPSHOT on localhost with PID 909 (/Users/majunwei/Documents/work/spring-boot-tutorial/spring-boot-tutorial-executable/target/spring-boot-tutorial-executable-0.0.1-SNAPSHOT.jar started by majunwei in /users/majunwei/documents/work/spring-boot-tutiorial/spring-boot-tutorial-excutable/target) 2017-08-04 12 : 05 : 58.926 정보 909 --- [main] osbtutorial.executable.epplication : 활성 프로파일 세트 없음, 기본 프로파일로 돌아 가기 : Default2017-09 12 : 05 : 05 : 05 : 05 : 05 : 05 : 05 : 05 : 05 : 05 : 05 : 05 : 05 : 05 : 05 : 05 : 05 : [Main] AtionConfigemeddedWebApplicationContext : 새로 고침 org.springframework.boot.context.embedded.annotationConfigemeddedWebApplicationContext@27F8302d : 시작 날짜 [Fri 04 12:05:59 cst 2017]; 컨텍스트의 루트 계층 2017-08-04 12 : 06 : 01.030 정보 909 --- [메인] SBCETTOMCATEMBEDDEDSERVLETCONTAINER : 포트 (S)로 초기화 된 TOMCAT : 8080 (HTTP) 2017-08-04 12 : 06 : 01.050 정보 909-- [메인] O.Apache.catalina.core.standardService : 시작 서비스 [Tomcat] 2017-08-04 12 : 06 : 01.053 정보 909 --- [Main] org.apache.catalina.core.standardEndine : 시작 서브 엔진 : Apache Tomcat/8.5.162017-08-04 12 : 01.224 정보. [OST-StartStop-1] Occc [Tomcat]. [LocalHost]. [/]. 12 : 06 : 01.430 Info 909 --- [OST-StartStop-1] OSBWSERVLET.SERVLETREGISTRATION : 매핑 서브 : 'DispatcherserVlet'에 [/] 2017-08-04 12 : 06 : 01.437 정보 909 --- [OST-StarStop-1] OSBWSERVLET.FILTERREGSTROTION : MAPED BEAN : MAPPENTBEN : '문자 인코딩 필터'to : [/*] 2017-08-04 12 : 06 : 01.437 Info 909 --- [OST-StartStop-1] OSBWSERVLET.FILTERREGISTRATIONBEAN : 매핑 필터 : 'HiddenHtttpMethodFilter'to : [/*] 2017-08-04 12 : 06 : 01.438. [OST-StartStop-1] OSBWSERVLET.FILTERREGISTRATIONBEAN : 매핑 필터 : 'HTTPPUTFORMCONTENTFILTER'TO : [/*] 2017-08-04 12 : 06 : 01.439 정보 909 --- [OST-StartStop-1] OSBWSERVLET.FILTERREGISTION : MAPPING FILT : 'restCONTCOTETFILTERREGISTION :' ' [/!! @controlleradvice : org.springframework.boot.context.embedded.annotationConfigemeddedWebApplicationContext@27f8302d : 시작 날짜 [Fri 04 12:05:59 CST 2017]; 컨텍스트의 루트 Hierarchy2017-08-04 12 : 06 : 02.019 Info 909 --- [Main] SWSMMAREQUESTMAPPINGHANDLERMPAPP : "{[/]}" "java.lang.String org.spring.boot.tutorial.executable.application.application.home () 2017-08-04 12 : 06 : 06 : 06 : 06 : 06 : 06 : 06 : 06 : 02. 909 --- [Main] SWSMMAREQUESTMAPPED HANDLERMPAPT : "{[/ERROR]}" "공개 org.springframework.http.responseentity <java.util.map <java.lang.string, java.lang.object >>에 매핑되었습니다. org.springframework.boot.autoconfigure.web.basicerrorcontroller.error (javax.servlet.http.httpservletrequest) 2017-08-04 12 : 06 : 06 : 06 : 06 : 06 : 06 : 02. "{[/error], public org.springframework.web.servlet.modelandview에 = [text/html]}"를 생성합니다 org.springframework.boot.autoconfigure.web.basicerrorcontroller.errorhtml (javax.servlet.http.httpservletrequest, javax.servlet.http.httpervletresponse) 2017-08-04 12 : 06 : 062 info 909--- 062. OSWSHANDLER.SIMPLEURLHANDLERMAPPING : MAPPED URL 경로 [/webjars/**] 유형의 처리기 [class org.springframework.web.servlet.resource.resource.resourcehttprequesthandler] 2017-08-04 12 : 06 : 02.062 info : [Main]] 유형의 핸들러에 대한 URL 경로 [/**] [클래스 org.springframework.servlet.resource.resourcehttprequesthandler] 2017-08-04 12 : 06 : 02.129 정보 909 --- [Main] OswShandler.simpalurlhandlermpaping : mapped [/simplhandlermapping : on on on one on on one on onf on on one on on one on on on on one on on on on on on on on on on on on on on on on on on. org.springframework.web.servlet.resource.resourcehttprequesthandler] 2017-08-04 12 : 06 : 02.344 Info 909 --- [Main] OsjeaAnnotationMbeanPporter : startup2017-08-04 12 : 06 : 02.448 정보. SBCETTOMCATEMBEDDEDSERVLETCONTAINER : TOMCAT는 항구에서 시작되었습니다 : 8080 (HTTP) 2017-08-04 12 : 06 : 02.458 정보 909 --- [MAIN] OSBTUTORION.EXECUTEABLE.APPLICATION : 4.054 초의 신청 시작 (4.622 년 JVM 실행)4 단계 : 이전과 마찬가지로 응용 프로그램을 종료하려면 CTRL-C를 누릅니다.
이 튜토리얼의 소스 코드를 다운로드하십시오
위는이 기사의 모든 내용입니다. 모든 사람의 학습에 도움이되기를 바랍니다. 모든 사람이 wulin.com을 더 지원하기를 바랍니다.