Why exec: java work and exec: exec fail?

just set up a simple project to test the functionality of the maven exec plugin. I have one class containing one of the main Hello World methods. I tested two exec plugin configurations.

<goals> <goal>exec</goal> </goals> <configuration> <executable>java</executable> <arguments> <argument>-classpath</argument> <classpath/> <argument>test.exec.HelloWorldExec</argument> </arguments> </configuration> 

failed unsuccessfully by giving me a ClassNotFoundException, and

  <goals><goal>java</goal></goals> <configuration> <mainClass>test.exec.HelloWorldExec</mainClass> </configuration> 

worked. However, I would like to start my main Java class in a separate process, so I would like to understand what is different from exec: exec and how can I make it work?

Any help appreciated

amuses

Wisse

+4
source share
2 answers

This error may be due. A workaround is included in the description, hope that helps :-)

If the workaround does not help, you can still vote for the error to increase the likelihood of a quick fix.

+2
source

I can not reproduce version 1.1 exec-maven-plugin. I created a sample project:

 $ mvn archetype:generate -DgroupId=com.stackoverflow.q2433572 -DartifactId=q2433572 -Dversion=1.0-SNAPSHOT $ cd q2433572 

I added the following plugin configuration in pom.xml:

 <project> ... <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.1</version> <goals> <goal>exec</goal> </goals> <configuration> <executable>java</executable> <arguments> <argument>-classpath</argument> <classpath/> <argument>com.stackoverflow.q2433572.App</argument> </arguments> </configuration> </plugin> </plugins> </build> </project> 

And this is the result that I get when running mvn exec:exec :

  $ mvn exec: exec
 [INFO] Scanning for projects ...
 [INFO] ----------------------------------------------- -------------------------
 [INFO] Building q2433572
 [INFO] task-segment: [exec: exec]
 [INFO] ----------------------------------------------- -------------------------
 [INFO] [exec: exec {execution: default-cli}]
 [INFO] Hello World!
 [INFO] ----------------------------------------------- -------------------------
 [INFO] BUILD SUCCESSFUL
 [INFO] ----------------------------------------------- -------------------------
 [INFO] Total time: 2 seconds
 [INFO] Finished at: Fri Mar 12 17:11:38 CET 2010
 [INFO] Final Memory: 3M / 53M
 [INFO] ----------------------------------------------- -------------------------

Works as expected.

0
source

Source: https://habr.com/ru/post/1303942/


All Articles