标签:
公司项目中遇到并要解决的问题
1:原则上除了自己写的代码之外,公共的jar不应该都在打包的时候打包到ear里面,这样的话包太大,也不符合的分层的逻辑,在jboss容器内部,每个ear的包重复jar都会调入jboss内部,而造成浪费过多地的服务器资源,会出现不定期的异常。
2:jboss eap 6.*系列,需要模块化配置,需要加载的jar,解决如何在jboss里面配置
3:公共的jar在jboss里面已经配置,加载……但是源码运行的时候不能根据maven的配置,加载jar的路径的问题
配置mysql和oracle驱动的方式,详情看我的博客不在重复
http://blog.csdn.net/lishehe/article/details/43069361
我们现在把相关的spring的公共的jar、shiro等等抽取到jboss模块中配置,在自己的jboss下的modules模块中,添加相关的jar的配置即可
<scope>provided</scope>
这句话的意思就是在我们开发、编译的时候会加载jar,在打包的时候不会打入到ear包内部,而会自动通过容器提供的jar来加载
如下
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-cas</artifactId>
<version>${shiro.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>${ehcache.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jasig.cas.client</groupId>
<artifactId>cas-client-core</artifactId>
<version>${cas.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
<scope>provided</scope>
</dependency>
<dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>${hibernate.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-mapper-asl</artifactId> <version>1.9.13</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>${javaee-api.version}</version> <scope>provided</scope> </dependency>
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<sub-deployment name="itoo-authority-role-web-0.0.1-SNAPSHOT.war">
<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.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>
第四步
这样的话,我们大部分的公共的jar都不会打入到ear包中,现在的测试的ear经过咱们整合之后,会在6M左右
总结
整个解决问题的过程中,更多的是查找英文资料和文档,相信解决问题的办法总比困难多……
JBOSS EAP 6 系列六 公共模块的jar配置到jboss的modules详细配置
标签:
原文地址:http://blog.csdn.net/lishehe/article/details/46287959