Javaweb resin4如何配置端口虛擬目錄
在JAVA WEB容器大家族中,Resin可以算的上最輕巧最快速的服務器了。我個人非常喜歡在產(chǎn)品開發(fā)階段使用Resin來測試和調試,因為開發(fā)階段需要頻繁地重啟服務器。在給客戶進行產(chǎn)品部署的時候我還是趨向于使用Tomcat,因為tomcat是全部免費的,而且使用者很多,再加上NIO和GZip模式可以優(yōu)化服務器性能以及tomcat出色的穩(wěn)定性。
Resin4可以給不同的Web app分配不同的端口,也就是說Resin4可以同時開啟多個端口的服務,這一點是非常贊的,在tomcat中想要實現(xiàn)這個就必須另外再來一份tomcat,配置不同的端口。而Resin4就不需要了,給不同的應用設置好相應的端口就OK了。
Resin4有一個全局端口,也就是默認端口,可以在conf/resin.properties文件中,對HTTP元素進行簡單的修改,如下:
# Set HTTP and HTTPS ports
http : 8080
#https : 8443
在Resin中創(chuàng)建虛擬目錄的方式是修改conf/resin.xml文件,正如我剛剛說的,每一個虛擬目錄都是一個Web app,都可以配置獨立的端口號。在resin.xml中一個cluster就代表一個端口應用,代碼如下:
<cluster id="app"> <!-- define the servers in the cluster --> <server-multi id-prefix="app-" address-list="${app_servers}" port="6800" /> <host-default> <!-- creates the webapps directory for .war expansion --> <web-app-deploy path="webapps" expand-preserve-fileset="WEB-INF/work/**" multiversion-routing="${webapp_multiversion_routing}" /> </host-default> <!-- auto virtual host deployment in hosts/foo.example.com/webapps --> <host-deploy path="hosts" /> <!-- the default host, matching any host name --> <host id="" root-directory="."> <!-- - webapps can be overridden/extended in the resin.xml --> <web-app id="/" root-directory="webapps/ROOT" /> <web-app id="/jPress" root-directory="D:\workspace\java\myeclipse10\jPress\WebRoot" /> <resin:if test="${resin_doc}"> <web-app id="/resin-doc" root-directory="${resin.root}/doc/resin-doc" /> </resin:if> </host> </cluster>
這個cluster是web-app的主簇,在其中添加<web-app>標簽就可以配置虛擬目錄了,這時候這個應用是使用默認端口進行部署的。如果要給這個簇配置特定的端口號,可以在cluster標簽第一個元素前面加上<server-default>標簽,如下:
<resin xmlns="http://caucho.com/ns/resin" xmlns:resin="urn:java:com.caucho.resin"> <cluster-default> <!-- shared configuration across all clusters --> <resin:import path="classpath:META-INF/caucho/app-default.xml" /> <resin:import path="${__DIR__}/health.xml" optional="true" /> </cluster-default> <cluster id="my-cluster"> <server-default> <!-- thread limits, JVM config, keepalives, ports, HTTP --> <http port="8083" /> </server-default> <host id="www.myhost.com" root-directory="hosts/myhost.com"> <resin:MovedPermanently regexp="/old-file" target="/new-path" /> <web-app-deploy path="webapps" expand-preserve-fileset="WEB-INF/work/**" /> <web-app id="/custom"> </web-app> </host> </cluster> </resin>
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
PowerJob的GridFsManager工作流程源碼解讀
這篇文章主要為大家介紹了PowerJob的GridFsManager工作流程源碼解讀,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2024-01-01Idea?springboot?springCloud熱加載熱調試兩種常用方式
這篇文章主要介紹了Idea?springboot?springCloud熱加載熱調試常用的兩種方式,在項目開發(fā)的過程中,需要修改調試的時候偶每次都需要重啟項目浪費時間,下面是我整理的兩種常用的兩種方式,需要的朋友可以參考下2023-04-04springboot之Validation參數(shù)校驗詳細解讀
這篇文章主要介紹了springboot之Validation參數(shù)校驗詳細解讀,本篇是關于springboot的參數(shù)校驗知識,當然也適用其它java應用,讀完本篇將學會基本的參數(shù)校驗,自定義參數(shù)校驗和分組參數(shù)校驗,需要的朋友可以參考下2023-10-10