简体   繁体   中英

Maven multi-project library dependency

I have the enterprise project (*.ear), what packaged by maven. Ear file have include many files:

final.ear
|-lib
|-META-INF 
|--web.war
|--bla-bla.jar
|--web-bla.war

Each file (jar, war) packaged by maven.
1) How put all required libraries from all files (war, jar) into final.ear/lib?
2) How group libraries from /lib, for example: lib/axis, lib/logging?

使用Maven EAR插件-瘦身战争功能对我来说很好解决了这个问题。

1 EJB jar) in the pom.xml of the jar make the dependency "not provided" so Maven knows the dependency is needed on the runtime classpath and thus to be deployed with the application - that will trigger it to add it to the ear/lib.

1 war) Basically what you describe here is that "instead of packaging the dependency with the war, package it in the parent EAR". In Maven terms you then add the dependency to the pom.xml of the ear (so it is on the runtime classpath there), and you mark the dependency as provided in the pom.xml of the war (so it is on the compile time classpath but not on the runtime classpath there). OR use the skinny wars feature as Steve C suggests.

2) The only way I would see this happening is if you micromanage the dependencies in the pom.xml of the ear entirely:

http://maven.apache.org/plugins/maven-ear-plugin/examples/customizing-module-location.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM