在我的 pom.xml 文件中,我有:
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>1.1.0</version>
</dependency>
现在,在我的源代码中我有这样一行:
import org.apache.hadoop.util.ProgramDriver;
当我运行 mvn install 时,所有代码都可以完美编译。但是,当我运行 mvn exec:java 时,出现类未找到错误 - 无法找到 org.apache.hadoop.util.ProgramDriver。
为什么我能够安装代码但无法运行它?谢谢。
我正在使用 org.codehaus.mojo 执行插件。
不起作用的配置:
<mainClass>myMainClass</mainClass>
<executableDependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
</executableDependency>
最佳答案
检查this
只需将其添加到您的 pom.xml
<configuration>
<executable>java</executable>
<arguments>
<argument>-Dmyproperty=myvalue</argument>
<argument>-classpath</argument>
<!-- automatically creates the classpath using all project dependencies,
also adding the project build directory -->
<classpath/>
<argument>com.example.Main</argument>
...
</arguments>
</configuration>
关于java - Maven安装但不会执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17981205/