Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.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
Java 如何从依赖工件获取资源文件_Java_Maven_Dependency Management - Fatal编程技术网

Java 如何从依赖工件获取资源文件

Java 如何从依赖工件获取资源文件,java,maven,dependency-management,Java,Maven,Dependency Management,我想从依赖项中获取资源文件,并将其放在我的类路径或其他目录中。我尝试了maven依赖插件,但似乎没有正确配置它。有人知道怎么做吗 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.3</version> &l

我想从依赖项中获取资源文件,并将其放在我的类路径或其他目录中。我尝试了maven依赖插件,但似乎没有正确配置它。有人知道怎么做吗

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.3</version>
    <executions>
         <execution>
         <id>get browsers.xml</id>
         <goals>
             <goal>unpack-dependencies</goal>
         </goals>
         <phase>generate-resources</phase>
         <configuration>
               <includeGroupIds>ru.fad.autotests</includeGroupIds>
               <includeArtifactIds>selenium-grid-browsers-local</includeArtifactIds>
               <includes>browsers.xml</includes>
               <outputDirectory>resources/</outputDirectory>
         </configuration>
         </execution>
      </executions>
  </plugin>

org.apache.maven.plugins
maven依赖插件
2.3
获取browsers.xml
解包依赖项
产生资源
ru.fad.autotests
selenium网格浏览器本地
browsers.xml
资源/

我将文件“browsers.xml”放在另一个工件中,并希望将其复制到我的目录中。

有几种不同的方法来解决这个问题,但我认为最有效的解决方案是使用特定的目标


与其将依赖项解包到
资源/
(应该是仅受版本控制的文件),不如将所需的工件解包到
目标/
,例如,
target/my resources/
并从build helper中引用该目录。

请共享确切的代码并详细说明您尝试执行的操作。您能否更具体地说明“将其复制到我的目录”的含义?您的项目结构中的哪个目录?另外,“但我似乎没有正确配置”-你能详细说明一下吗?与您希望它做的事情相比,它目前正在做什么(错误?)?我的文件“browsers.xml”位于依赖工件的资源中。我必须将它复制到src/main/resources目录中。我没有收到任何错误。但此配置将meta-pom.xml和browsers.xml复制到目标目录。我不知道为什么:)怎么才能做好?