当把第三方的jar(本文以mysql为例,具体配置参见http://blog.csdn.net/sundongsdu/article/details/8840389)以module的方式部署到jboss7的时候,有三种方式:
方式一> 以mysql为例,在META-INF/MANIFEST.MF
里添加一行
Dependency: mysql
如果依赖多个module, 中间用逗号分隔
这个可以通过maven的pom.xml中配置实现:
<build>
...
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Dependencies>mysql</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
方式二> 配置jboss-deployment-structure.xml
对于以war方式部署,则添加配置WEB-INF/jboss-deployment-structure.xml
内容如下:
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
<deployment>
<dependencies>
<module name="mysql"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
方式三> 如果希望这个module被所有部署的应用使用,那么可以将其设置为global module:
编辑standalone/configuration/standalone.xml:
<subsystem xmlns="urn:jboss:domain:ee:1.0">
<global-modules>
<module name="mysql" slot="main" />
</global-modules>
</subsystem>
参考文献:https://docs.jboss.org/author/display/AS71/Class+Loading+in+AS7