当前位置: 移动技术网 > IT编程>开发语言>Java > Javaweb resin4如何配置端口虚拟目录

Javaweb resin4如何配置端口虚拟目录

2020年07月26日  | 移动技术网IT编程  | 我要评论

在java web容器大家族中,resin可以算的上最轻巧最快速的服务器了。我个人非常喜欢在产品开发阶段使用resin来测试和调试,因为开发阶段需要频繁地重启服务器。在给客户进行产品部署的时候我还是趋向于使用tomcat,因为tomcat是全部免费的,而且使用者很多,再加上nio和gzip模式可以优化服务器性能以及tomcat出色的稳定性。

resin4可以给不同的web app分配不同的端口,也就是说resin4可以同时开启多个端口的服务,这一点是非常赞的,在tomcat中想要实现这个就必须另外再来一份tomcat,配置不同的端口。而resin4就不需要了,给不同的应用设置好相应的端口就ok了。

resin4有一个全局端口,也就是默认端口,可以在conf/resin.properties文件中,对http元素进行简单的修改,如下:

# set http and https ports
http : 8080
#https : 8443

在resin中创建虚拟目录的方式是修改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>

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网