java - 添加附加路径到 exec-maven-plugin

标签 java maven-2 maven-plugin

我想向 exec-maven-plugin 添加一个额外的类路径。
除了 %classpath 之外,我还想添加一个额外的路径到包含资源的目录 (/Users/kornp/resources)。 目前,我的 pom 看起来像这样:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <version>1.1.1</version>
  <configuration>
    <executable>java</executable>
    <classpathScope>runtime</classpathScope>
    <arguments>
      <argument>%classpath:/Users/kornp/resources</argument>
      <argument>org.drrabbit.maventest.App</argument>
    </arguments>
  </configuration>
</plugin>

我该如何配置?

最佳答案

我在源文件夹之外的特定目录中有一些配置文件。所以我为我的 pom.xml 文件定义了额外的资源。

我的示例目录结构是:

+ src
+ conf
  - app.properties
  - log4j.xml
- pom.xml

我的 pom.xml:

<build>
  <resources>
    <resource>
      <directory>conf</directory>
    </resource>
    <resource>
      <directory>src/main/resources</directory>
    </resource>
  </resources>

  <plugins>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>exec-maven-plugin</artifactId>
      <version>1.2.1</version>
      <configuration>
        <executable>java</executable>
        <mainClass>com.mycompany.MyMainClass</mainClass>
      </configuration>
    </plugin>
  </plugins>
<build>

现在我们可以执行程序了:

mvn clean compile exec:java

关于java - 添加附加路径到 exec-maven-plugin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2587935/

相关文章:

java - 集成java + php swagger

java - Workspace 定义了一个不包含有效 jre/lib/rt.jar : C:\Program Files\Java\jre7 的 VM

java - 如何用maven编译单个文件?

java - 无法使用 Maven 依赖项在 m2 存储库中下载 .jar 文件

java - 有没有办法让 Maven 同时构建 1.5 和 1.6 字节码 jar?

maven - 如何在一个 Maven 命令中运行两个配置文件?

maven - 仅当运行插件时依赖项才位于类路径中

java - 动态访问 alfresco-global.properties

java - 递归语句调用另一个递归语句?

java - XWPF 列超出 docx 文档边界(Ubuntu 16.04 主机)