在项目中由于从jboss向tomcat切换。需要考虑一些问题,最终确定了下来。
jboss是ejb容器,可以运行ejb应用,支持ear包。而Tomcat只是servlet容器,只能运行web应用,只能打成war包。
在jboss中的modules目录里有system的文件夹,是jboss自带的jar包,启动时会自动加载。
而其它文件夹是用户自己创建的,放着工程中一些公共的运行时jar包。可以按需加载,具体在jboss-deployment-structure.xml中配置,具体的位置:
需要哪些jar包在里面声明哪些jar包。
还以上图内容举例:
<?xml version="1.0" encoding="UTF-8"?> <jboss-deployment-structure> <deployment> <exclusions> <module name="org.apache.log4j" /> <module name="org.slf4j" /> <module name="org.apache.commons.logging" /> <module name="org.log4j" /> <module name="org.jboss.logging" /> </exclusions> </deployment> <sub-deployment name="itoo-freshmen-insurance-core.jar"> <exclusions> <module name="org.apache.log4j" /> <module name="org.slf4j" /> <module name="org.apache.commons.logging" /> <module name="org.log4j" /> <module name="org.jboss.logging" /> </exclusions> <dependencies> <module name="org.jboss.xnio" /> <module name="org.apache.shiro"> <imports> <include path="META-INF**" /> <include path="org**" /> </imports> </module> <module name="org.jasig.cas.client"> <imports> <include path="META-INF**" /> <include path="org**" /> </imports> </module> <module name="org.springframework.data"> <imports> <include path="META-INF**" /> <include path="org**" /> </imports> </module> <module name="org.crazycake"> <imports> <include path="META-INF**" /> <include path="org**" /> </imports> </module> <module name="commons-fileupload"> <imports> <include path="META-INF**" /> <include path="org**" /> </imports> </module> <module name="org.codehaus.jackson"> <imports> <include path="META-INF**" /> <include path="org**" /> </imports> </module> <module name="redis.clients"> <imports> <include path="META-INF**" /> <include path="org**" /> </imports> </module> <module name="org.eclipse.persistence"> <imports> <include path="META-INF**" /> <include path="org**" /> </imports> </module> <module name="commons-lang"> <imports> <include path="META-INF**" /> <include path="org**" /> </imports> </module> <module name="org.apache.commons.commons-pool2"> <imports> <include path="META-INF**" /> <include path="org**" /> </imports> </module> <module name="org.springframework"> <imports> <include path="META-INF**" /> <include path="org**" /> </imports> </module> </dependencies> </sub-deployment> <sub-deployment name="itoo-freshmen-insurance-web.war"> <exclusions> <module name="org.apache.log4j" /> <module name="org.slf4j" /> <module name="org.apache.commons.logging" /> <module name="org.log4j" /> <module name="org.jboss.logging" /> </exclusions> <dependencies> <module name="org.jboss.xnio" /> <module name="org.apache.shiro"> <imports> <include path="META-INF**" /> <include path="org**" /> </imports> </module> <module name="org.jasig.cas.client"> <imports> <include path="META-INF**" /> <include path="org**" /> </imports> </module> <module name="org.springframework.data"> <imports> <include path="META-INF**" /> <include path="org**" /> </imports> </module> <module name="org.crazycake"> <imports> <include path="META-INF**" /> <include path="org**" /> </imports> </module> <module name="commons-fileupload"> <imports> <include path="META-INF**" /> <include path="org**" /> </imports> </module> <module name="org.codehaus.jackson"> <imports> <include path="META-INF**" /> <include path="org**" /> </imports> </module> <module name="redis.clients"> <imports> <include path="META-INF**" /> <include path="org**" /> </imports> </module> <module name="org.eclipse.persistence"> <imports> <include path="META-INF**" /> <include path="org**" /> </imports> </module> <module name="commons-lang"> <imports> <include path="META-INF**" /> <include path="org**" /> </imports> </module> <module name="org.apache.commons.commons-pool2"> <imports> <include path="META-INF**" /> <include path="org**" /> </imports> </module> <module name="org.springframework"> <imports> <include path="META-INF**" /> <include path="org**" /> </imports> </module> </dependencies> </sub-deployment> </jboss-deployment-structure>
而tomcat自带的一些jar包在lib下。
当tomcat启动的时候讲会加载这些jar包。目前了解到,tomcat没有按需加载的机制,所以工程中一些公共的运行时jar包放到这里会全部加载。
Java中有三种xAR文件:JAR/WAR/EAR
JAR:Java ARchieve
WAR:Web ARchieve
EAR:Enterprise ARchieve
用UML类图表示他们之间的关系:
