介绍
上一章介绍了在定义模块时,模块描述文件是怎样的结构以及有哪些选项。这一张将讨论打包成jar的应用如何申明对其它模块的依赖关系。
例如,如果你有一个用jar打包的应用并且想使用JBoss Modules来运行它。在这种情况下,我们需要有一种方式来告诉JBoss Modules 我们的应用依赖哪些模块,以便那些模块中的classes和resources能够被我们的应用所使用。要做到这一点,可以使用一个 manifest 文件。
在Manifest定义依赖
manifest依赖用来定义一个jar的依赖关系。下面是一个例子:
Dependencies: org.some.module, org.another.module
你也可以指定 version slot,跟在模块名字的后面:
Dependencies: org.some.module:main, org.another.module:1.0
将依赖配置到POM
下面是一个怎样将依赖关系配置到Maven pom.xml 的例子:
<plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.3.1</version> <configuration> <archive> <manifestEntries> <Dependencies>org.some.module, org.another.module</Dependencies> </manifestEntries> </archive> </configuration> </plugin> </plugins>