加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – 添加exec-maven-plugin的附加路径

发布时间:2020-12-15 01:00:40 所属栏目:Java 来源:网络整理
导读:我想为exec-maven-plugin添加一个额外的类路径. 除了%classpath,我想添加一个额外的路径到包含资源的目录(/ Users / kornp / resources). 目前,我的pom看起来像这样: plugin groupIdorg.codehaus.mojo/groupId artifactIdexec-maven-plugin/artifactId ver
我想为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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读