How to write a Maven build script to execute Java

混江龙づ霸主 提交于 2019-12-04 10:47:01
cetnar

Configure maven-exec-plugin with your pom

<build>
<plugins>
  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.1</version>
    <executions>
      <execution>
        <phase>yourPhase</phase>
        ...
        <goals>
          <goal>java</goal>
        </goals>
           <configuration>
             <mainClass>mainClass=org.sonatype.mavenbook.weather.Main</mainClass>
          </configuration>
      </execution>
    </executions>
  </plugin>
</plugins>
</build>

In line <phase>yourPhase</phase> insert maven phase in what this plugin should run.

This class need to be avaliable in pom classpath (as source or as a dependency). In other case if it shouldn't be a project dependency read this article how to configure a exec plugin.

Try the exec maven plugin... Oops, I should've read more carefully :-(

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!