Maven:如何使用 maven-ear-plugin 将文件添加到 EAR 内的根目录?
我需要在使用 maven-ear-plugin 生成的 EAR 中添加 2 个 XML 文件。
不幸的是,我还没有找到将任意文件添加到 EAR 的方法;插件的文档,内容为“EAR 插件支持以下工件: ejb、war、jar、ejb-client、rar、ejb3、par、sar、wsr 和 har”。没有什么可以添加常规文件。
org.apache.maven.plugins maven-ear-插件 2.3.1 富 富 1.4 库 ${parent.groupId} foo-web /foo org.richfaces.framework richfaces-api 公共语言 公共语言
非常感谢。
I need to add 2 XML files inside an EAR generated with maven-ear-plugin.
Unfortunately, I haven't seen a way to add an arbitrary file to an EAR; the documentation of the plugin which reads "The EAR plugin supports the following artifacts: ejb, war, jar, ejb-client, rar, ejb3, par, sar, wsr and har". There's nothing for adding a regular file.
org.apache.maven.plugins
maven-ear-plugin
2.3.1
foo
foo
1.4
lib
${parent.groupId}
foo-web
/foo
org.richfaces.framework
richfaces-api
commons-lang
commons-lang
Many thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 maven-ear-plugin 2.4.2 中,您可以使用配置元素earSourceDirectory、earSourceExcludes 和earSourceInincludes 来声明要包含在EAR 中的额外文件。
默认情况下,您只需将这些文件放置到 ${basedir}/src/main/application 文件夹中即可。
In maven-ear-plugin 2.4.2 you can use config elements earSourceDirectory, earSourceExcludes and earSourceIncludes to declare extra files to include in the EAR.
By default you simply place those files to ${basedir}/src/main/application folder.
我有同样的问题。我在 ejbs/src/main/resources 下有 ejb.properties 文件,并使用earSourceDirectory 和earSourceInincludes 将文件从ejbs 目录拉到ear。然而,它并没有可靠将其放入lib目录中。 EJB 在 . 中找不到它;它在 lib 目录中查找它。
为了解决这个问题,我创建了 src/main/application/lib 目录并创建了指向 ejb.properties 文件的链接。然后我删除了 EarSourceDirectory 和 Includes 属性。现在,当我执行 mvn clean 打包时,它会自动拉取属性文件并将其放入 Ear 的 lib 目录中。
I had the same issue. I had the ejb.properties file under ejbs/src/main/resources and had used earSourceDirectory and earSourceIncludes to pull the file from the ejbs directory to the ear. However, it did not reliably put it in the lib directory. The EJB does not find it in .; it looks for it in the lib directory.
To fix this, I created the src/main/application/lib directory and created a link to the ejb.properties file. I then removed the earSourceDirectory and Includes properties. Now when I do a mvn clean package, it automatically pulls the properties file and puts it in the lib directory of the ear.
很抱歉@wishihadabettername 迟到了,但我最近遇到了同样的问题,更多的是我无法移动要包含的文件,因为它们位于earSourceDirectory 之外的其他文件夹中。我阅读了 maven-ear-plugin Ear:ear 文档 并思考如何将我的
release
文件夹移动到耳朵根部。和
然后我的子模块 pom.xml 看起来像这样:
希望从现在起它可以帮助人们
Sorry to be late for @wishihadabettername but I had same issue recently, more I couldn't move the files to include because they were in other folder then earSourceDirectory. I read maven-ear-plugin ear:ear documentation and thought about how to move my
release
folder on the root of ear.and
Then my submodule pom.xml looks like this:
Hope it help people from now on