我尝试使用 exec-maven-plugin 来运行 Java 程序。
我使用以下 pom 片段:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<executable>java</executable>
<arguments>
<argument>-Dmyproperty=myvalue</argument>
<argument>-cp</argument>
<argument>"/home/vogella/libs/*"</argument>
<argument>com.vogella.test.Main</argument>
</arguments>
</configuration>
</plugin>
该类com.vogella.test.Main
包含在位于 /home/vogella/libs/* 中的 jar 文件之一中。如果我运行该mvn -X clean install exec:exec
命令,我会看到以下错误消息:
[调试] 执行命令行:java -Dmyproperty=myvalue -cp "/home/vogella/libs/*" com.vogella.test.Main 错误:找不到或加载主类 com.vogella.test.Main
如果我在启动 Maven 构建的 shell 中复制命令行 ( java -Dmyproperty=myvalue -cp "/home/vogella/libs/*" com.vogella.test.Main
),则 Java 程序将正确执行。
知道我的 Maven 设置有什么问题吗?