我想向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

09-25 18:46
查看更多