国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
JETTY9(9.2.1)入門學(xué)習(xí)

下載的jetty-distribution-9.2.1.v20140609,算是目前為止的最新版本,jetty的版本比較多,而且各種版本有一定的差異,感覺這點(diǎn)不如tomcat。

1.解壓jetty到指定的目錄,該目錄就是$(JETTY_HOME)

   進(jìn)入到該目錄,運(yùn)行java -jar start.jar,就可以啟動(dòng)jetty了。



2.運(yùn)行jetty的demo-base

  cd ${JETTY_HOME}/demo_base 目錄,運(yùn)行 java -jar ../start.jar 就可以啟動(dòng)demo-base并看到j(luò)etty的歡迎界面了。


3.修改jetty運(yùn)行端口

   (1)命令啟動(dòng)時(shí)指定端口號(hào): java -jar start.jar jetty.port=8081


   (2)修改配置文件: 修改${JETTY_HOME}/start.d/http.ini中指定的端口號(hào)。

4. 部署web應(yīng)用

    和tomcat相同,直接放到${JETTY_HOME}/webapps下面就行,看網(wǎng)上說還需要改什么設(shè)置,這里測(cè)試了一下,直接放上就可以啟動(dòng)。這里部署的是標(biāo)準(zhǔn)的web應(yīng)用。如果文件夾或者war包名稱是root,jetty視為根目錄。


5.熱部署

jettty可以通過監(jiān)控目錄的變化來部署應(yīng)用,如果你往目錄里面添加一個(gè)web應(yīng)用,jetty的部署管理器(DM deployment manager)就會(huì)部署一個(gè)新的上下文??梢酝ㄟ^配置文件修改相關(guān)的屬性,該文件的默認(rèn)位置是${JETTY_HOME}/etc/jetty-deploy.xml

  1. <span style="font-size:14px;"><?xml version="1.0"?>  
  2. <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">  
  3. <Configure id="Server" class="org.eclipse.jetty.server.Server">  
  4.    
  5.   <Call name="addBean">  
  6.     <Arg>  
  7.       <New id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager">  
  8.         <Set name="contexts">  
  9.           <Ref refid="Contexts" />  
  10.         </Set>  
  11.         <Call id="webappprovider" name="addAppProvider">  
  12.           <Arg>  
  13.             <New class="org.eclipse.jetty.deploy.providers.WebAppProvider">  
  14.               <Set name="monitoredDirName"><Property name="jetty.home" default="." />/webapps</Set>  
  15.               <Set name="defaultsDescriptor"><Property name="jetty.home" default="." />/etc/webdefault.xml</Set>  
  16.               <Set name="scanInterval">1</Set>  
  17.               <Set name="extractWars">true</Set>  
  18.             </New>  
  19.           </Arg>  
  20.         </Call>  
  21.       </New>  
  22.     </Arg>  
  23.   </Call>  
  24. </Configure></span>  

6.Maven和Jetty

使用嵌入式JETTY和MAVEN

MAVEN使用約定優(yōu)于配置,所以最好是使用MAVEN推薦的工程結(jié)構(gòu)??梢允褂胊rchetypes快速設(shè)置maven項(xiàng)目,現(xiàn)在為這個(gè)簡單的例子使用手工建立工程結(jié)構(gòu)。

  1. > mkdir JettyMavenHelloWorld  
  2. > cd JettyMavenHelloWorld  
  3. > mkdir -p src/main/java/org/example  

windows下可以使用md命令建立多級(jí)目錄,在路徑src/main/java/org/example/下建立HelloWorld.java類,內(nèi)容如下:

  1. package org.example;  
  2.    
  3. import javax.servlet.http.HttpServletRequest;  
  4. import javax.servlet.http.HttpServletResponse;  
  5. import javax.servlet.ServletException;  
  6. import java.io.IOException;  
  7. import org.eclipse.jetty.server.Server;  
  8. import org.eclipse.jetty.server.Request;  
  9. import org.eclipse.jetty.server.handler.AbstractHandler;  
  10.    
  11. public class HelloWorld extends AbstractHandler  
  12. {  
  13.     public void handle(String target,  
  14.                        Request baseRequest,  
  15.                        HttpServletRequest request,  
  16.                        HttpServletResponse response)   
  17.         throws IOException, ServletException  
  18.     {  
  19.         response.setContentType("text/html;charset=utf-8");  
  20.         response.setStatus(HttpServletResponse.SC_OK);  
  21.         baseRequest.setHandled(true);  
  22.         response.getWriter().println("<h1>Hello World</h1>");  
  23.     }  
  24.    
  25.     public static void main(String[] args) throws Exception  
  26.     {  
  27.         Server server = new Server(8080);  
  28.         server.setHandler(new HelloWorld());  
  29.     
  30.         server.start();  
  31.         server.join();  
  32.     }  
  33. }  

建立POM描述文件,pom.xml描述文件描述了工程的名稱和依賴,使用文本編輯器在JettyMavenHelloWorld目錄下建立pom.xml,內(nèi)容如下

  1. <project xmlns="http://maven.apache.org/POM/4.0.0"  
  2.          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  3.          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">  
  4.    
  5.   <modelVersion>4.0.0</modelVersion>  
  6.   <groupId>org.example</groupId>  
  7.   <artifactId>hello-world</artifactId>  
  8.   <version>0.1-SNAPSHOT</version>  
  9.   <packaging>jar</packaging>  
  10.   <name>Jetty HelloWorld</name>  
  11.    
  12.   <properties>  
  13.       <!-- Adapt this to a version found on  
  14.            http://central.maven.org/maven2/org/eclipse/jetty/jetty-maven-plugin/  
  15.         -->  
  16.       <jettyVersion>9.0.2.v20130417</jettyVersion>  
  17.   </properties>  
  18.    
  19.   <dependencies>  
  20.     <dependency>  
  21.       <groupId>org.eclipse.jetty</groupId>  
  22.       <artifactId>jetty-server</artifactId>  
  23.       <version>${jettyVersion}</version>  
  24.     </dependency>  
  25.   </dependencies>  
  26.    
  27.   <build>  
  28.     <plugins>  
  29.       <plugin>  
  30.         <groupId>org.codehaus.mojo</groupId>  
  31.         <artifactId>exec-maven-plugin</artifactId>  
  32.         <version>1.1</version>  
  33.         <executions>  
  34.           <execution><goals><goal>java</goal></goals></execution>  
  35.         </executions>  
  36.         <configuration>  
  37.           <mainClass>org.example.HelloWorld</mainClass>  
  38.         </configuration>  
  39.       </plugin>  
  40.     </plugins>  
  41.   </build>  
  42. </project>  
編譯和運(yùn)行HelloWorld.java類
  1. > mvn clean compile exec:java    
編譯成功后,可以訪問http://localhost:8080/會(huì)看到頁面中打印出HelloWorld字樣。






  1.   
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Maven初探
maven2 (二) SCM
在linux環(huán)境下安裝、配置、使用Maven
maven 的基本配置及個(gè)人理解
使用Maven創(chuàng)建Java項(xiàng)目
Maven通俗講解
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服