Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用类路径资源配置Maven插件?_Maven - Fatal编程技术网

如何使用类路径资源配置Maven插件?

如何使用类路径资源配置Maven插件?,maven,Maven,今天,我像这样配置Maven war插件: <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <webXml>${basedir}/../common/WEB-INF/web.xml</webXml> </configuration> org

今天,我像这样配置Maven war插件:

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
   <webXml>${basedir}/../common/WEB-INF/web.xml</webXml>
</configuration>
org.apache.maven.plugins
maven战争插件
${basedir}/./common/WEB-INF/WEB.xml
这允许我在多个项目之间共享web.xml。 这种方法的问题在于我的Maven项目不是自包含的。它取决于文件系统上的相对路径

这样做有可能吗

   <webXml>classpath:com/mycompany/common/web.xml</webXml>
<webXml>classpath:com/mycompany/common/web.xml</webXml>
classpath:com/mycompany/common/web.xml
当然,在插件的类路径上提供该文件


谢谢

第一步是创建一个专用的Maven模块,其打包类型为
jar
,包含
web.xml
。我们称之为com.mycompany:common

这样做有可能吗

   <webXml>classpath:com/mycompany/common/web.xml</webXml>
<webXml>classpath:com/mycompany/common/web.xml</webXml>

您可以使用绝对路径,如“D:\dev”,尝试在build/resources下添加文件位置。。。谢谢,我可以使用依赖插件。注意:classpath:不起作用(至少对于war插件是这样),它无论如何都会在文件系统中找到它。