Maven에서 Jetty를 움직입니다.
필요한 것
필요한 것은 다음과 같습니다. 세세한 버전은 최신을 사용하면 좋을까 생각합니다.
JAVA_HOME 및 Maven에 대한 경로를 통해 둡시다.
프로젝트 만들기
mvn 명령으로 프로젝트의 편지지를 만듭니다 (이하, 줄 바꿈)
> mvn archetype:generate -DarchetypeArtifactId=maven-archetype-webapp
-DgroupId=test.webapp -DartifactId=test-server -Dpackage=test.webapp
-DinteractiveMode=false
> mvn archetype:generate -DarchetypeArtifactId=maven-archetype-webapp
-DgroupId=test.webapp -DartifactId=test-server -Dpackage=test.webapp
-DinteractiveMode=false
아래 명령 실행시 출력 (처음에는 더 많은 다운로드 메시지가 표시 될 수 있습니다)
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.4:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.4:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.4:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Batch mode
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-webapp:1.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: basedir, Value: d:\temp\sample
[INFO] Parameter: package, Value: test.webapp
[INFO] Parameter: groupId, Value: test.webapp
[INFO] Parameter: artifactId, Value: test-server
[INFO] Parameter: packageName, Value: test.webapp
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: d:\temp\sample\test-server
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.179 s
[INFO] Finished at: 2015-12-03T22:33:13+09:00
[INFO] Final Memory: 13M/219M
[INFO] ------------------------------------------------------------------------
d:\temp\sample>
아키타입이 낡다고 INFO 됩니다만, 지금 바람의 지정 방법은가 있는지는 미조사. 폴더 구성은 다음과 같습니다.
D:.
└─test-server
└─src
└─main
├─resources
└─webapp
└─WEB-INF
pom.xml 편집
pom.xml은 Maven의 프로젝트 구성 파일(Project Object Model)입니다. 종속성 등을 설명합니다. h tp // mv 넙치와 ry. 코m/ 에서 필요한 라이브러리 찾기
아래에 pom.xml을 모두 붙여 넣습니다. 버전은 적절하게 변경하고, Jetty의 포트 번호도 defo에서 바꾸고 있습니다.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test.webapp</groupId>
<artifactId>test-server</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>test-server Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<jetty.version>9.3.6.v20151106</jetty.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>${jetty.version}</version>
</dependency>
</dependencies>
<build>
<finalName>test-server</finalName>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<configuration>
<httpConnector>
<port>8989</port>
</httpConnector>
</configuration>
</plugin>
</plugins>
</build>
</project>
실행
실행은 mvn jetty:run 을 실행하기만 하면 됩니다.
d:\temp\sample\test-server>mvn jetty:run
mvn jetty:run
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building test-server Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> jetty-maven-plugin:9.3.6.v20151106:run (default-cli) > test-compile @ test-server >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ test-server ---
[WARNING] Using platform encoding (MS932 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ test-server ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ test-server ---
[WARNING] Using platform encoding (MS932 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory d:\temp\sample\test-server\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ test-server ---
[INFO] No sources to compile
[INFO]
[INFO] <<< jetty-maven-plugin:9.3.6.v20151106:run (default-cli) < test-compile @ test-server <<<
[INFO]
[INFO] --- jetty-maven-plugin:9.3.6.v20151106:run (default-cli) @ test-server ---
[INFO] Logging initialized @2102ms
[INFO] Configuring Jetty for project: test-server Maven Webapp
[INFO] webAppSourceDirectory not set. Trying src\main\webapp
[INFO] Reload Mechanic: automatic
[INFO] Classes = D:\temp\sample\test-server\target\classes
[INFO] Context path = /
[INFO] Tmp directory = D:\temp\sample\test-server\target\tmp
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides = none
[INFO] web.xml file = file:///D:/temp/sample/test-server/src/main/webapp/WEB-INF/web.xml
[INFO] Webapp directory = D:\temp\sample\test-server\src\main\webapp
[INFO] jetty-9.3.6.v20151106
[INFO] Started o.e.j.m.p.JettyWebAppContext@469d003c{/,file:///D:/temp/sample/test-server/src/main/webapp/,AVAILABLE}{file:///D:/temp/sample/test-server/src/main/webapp/}
[INFO] Started ServerConnector@3b0ee03a{HTTP/1.1,[http/1.1]}{0.0.0.0:8989}
[INFO] Started @2819ms
[INFO] Started Jetty Server
http://localhost:8989/ 로 이동하여 Hello World가 표시되면 OK입니다.
이상
Reference
이 문제에 관하여(Maven에서 Jetty를 움직입니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/moris/items/4538773013d4e17ddecc
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
d:\temp\sample\test-server>mvn jetty:run
mvn jetty:run
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building test-server Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> jetty-maven-plugin:9.3.6.v20151106:run (default-cli) > test-compile @ test-server >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ test-server ---
[WARNING] Using platform encoding (MS932 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ test-server ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ test-server ---
[WARNING] Using platform encoding (MS932 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory d:\temp\sample\test-server\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ test-server ---
[INFO] No sources to compile
[INFO]
[INFO] <<< jetty-maven-plugin:9.3.6.v20151106:run (default-cli) < test-compile @ test-server <<<
[INFO]
[INFO] --- jetty-maven-plugin:9.3.6.v20151106:run (default-cli) @ test-server ---
[INFO] Logging initialized @2102ms
[INFO] Configuring Jetty for project: test-server Maven Webapp
[INFO] webAppSourceDirectory not set. Trying src\main\webapp
[INFO] Reload Mechanic: automatic
[INFO] Classes = D:\temp\sample\test-server\target\classes
[INFO] Context path = /
[INFO] Tmp directory = D:\temp\sample\test-server\target\tmp
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides = none
[INFO] web.xml file = file:///D:/temp/sample/test-server/src/main/webapp/WEB-INF/web.xml
[INFO] Webapp directory = D:\temp\sample\test-server\src\main\webapp
[INFO] jetty-9.3.6.v20151106
[INFO] Started o.e.j.m.p.JettyWebAppContext@469d003c{/,file:///D:/temp/sample/test-server/src/main/webapp/,AVAILABLE}{file:///D:/temp/sample/test-server/src/main/webapp/}
[INFO] Started ServerConnector@3b0ee03a{HTTP/1.1,[http/1.1]}{0.0.0.0:8989}
[INFO] Started @2819ms
[INFO] Started Jetty Server
Reference
이 문제에 관하여(Maven에서 Jetty를 움직입니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/moris/items/4538773013d4e17ddecc텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)