maven java 在 eclipse 之外构建错误
maven java build errors outside the eclipse
我通常 build/generate eclipse 中的 java 类 文件。但是,现在我需要让项目在没有 eclipse 的机器上运行,所以我直接使用 maven 从命令行构建它。然后我得到以下错误,我在这里遗漏了什么吗?谢谢!
Edamame$ mvn java:compile
[INFO] Scanning for projects...
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml (13 KB at 23.9 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml (20 KB at 36.1 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.023 s
[INFO] Finished at: 2015-07-09T07:23:05-07:00
[INFO] Final Memory: 9M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'java' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/Edamame/.m2/repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException
这里是 pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>edamame.hadoop</groupId>
<artifactId>myProject</artifactId>
<version>1.1</version>
<packaging>pom</packaging>
<name>EdamameProject</name>
<url>http://myEdamame.com</url>
<properties>
<jdkLevel>1.7</jdkLevel>
<requiredMavenVersion>[2.1,)</requiredMavenVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.outputEncoding>UTF-8</project.build.outputEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<source>${jdkLevel}</source>
<target>${jdkLevel}</target>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
:
</repositories>
<dependencies>
:
</dependencies>
</project>
此外,这是 "mvn compile" 的输出,它成功了,只是没有创建 target/classes 文件夹及其 类。
Edamame$ mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building myProject 1.1
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.073 s
[INFO] Finished at: 2015-07-09T08:26:12-07:00
[INFO] Final Memory: 6M/245M
[INFO] ------------------------------------------------------------------------
你应该去:mvn compile(或者甚至 mvn install 或类似的东西来测试它并制作一切)。
首先,您需要将 pom.xml 中的 <packaging>
值更改为 "pom" 以外的值,以使 Maven 运行 完全成为编译插件。试试 "jar".
然后,如果您只想编译源代码,请使用
mvn compile
如果您想要打包的 JAR,请致电
mvn package
我通常 build/generate eclipse 中的 java 类 文件。但是,现在我需要让项目在没有 eclipse 的机器上运行,所以我直接使用 maven 从命令行构建它。然后我得到以下错误,我在这里遗漏了什么吗?谢谢!
Edamame$ mvn java:compile
[INFO] Scanning for projects...
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml (13 KB at 23.9 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml (20 KB at 36.1 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.023 s
[INFO] Finished at: 2015-07-09T07:23:05-07:00
[INFO] Final Memory: 9M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'java' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/Edamame/.m2/repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException
这里是 pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>edamame.hadoop</groupId>
<artifactId>myProject</artifactId>
<version>1.1</version>
<packaging>pom</packaging>
<name>EdamameProject</name>
<url>http://myEdamame.com</url>
<properties>
<jdkLevel>1.7</jdkLevel>
<requiredMavenVersion>[2.1,)</requiredMavenVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.outputEncoding>UTF-8</project.build.outputEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<source>${jdkLevel}</source>
<target>${jdkLevel}</target>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
:
</repositories>
<dependencies>
:
</dependencies>
</project>
此外,这是 "mvn compile" 的输出,它成功了,只是没有创建 target/classes 文件夹及其 类。
Edamame$ mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building myProject 1.1
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.073 s
[INFO] Finished at: 2015-07-09T08:26:12-07:00
[INFO] Final Memory: 6M/245M
[INFO] ------------------------------------------------------------------------
你应该去:mvn compile(或者甚至 mvn install 或类似的东西来测试它并制作一切)。
首先,您需要将 pom.xml 中的 <packaging>
值更改为 "pom" 以外的值,以使 Maven 运行 完全成为编译插件。试试 "jar".
然后,如果您只想编译源代码,请使用
mvn compile
如果您想要打包的 JAR,请致电
mvn package