【发布时间】:2016-11-25 13:46:05
【问题描述】:
我正在尝试在 Eclipse Luna 环境中使用 maven 来组装可执行 jar 并将其部署到 Raspberry Pi,我发现看起来像一个合适的 Maven 脚本,但 Maven 似乎没有找到它的第一个插件和声明构建失败,请参阅下面的控制台日志:-
[INFO] Scanning for projects...
[INFO] Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml
[INFO] Downloading: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml
[INFO] Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml (13 KB at 21.6 KB/sec)
[INFO] Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml (20 KB at 32.6 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.404 s
[INFO] Finished at: 2016-07-21T20:01:39+01:00
[INFO] Final Memory: 12M/164M
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'maven-assembly-plugin' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\GJWood\.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>com.company</groupId>
<artifactId>RPITank</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<!-- DEFAULT RASPBERRY PI PROPERTIES -->
<pi.host>192.168.1.123</pi.host>
<pi.port>22</pi.port>
<pi.user>pi</pi.user>
<pi.password>raspberry</pi.password>
<pi.deployDirectory>/home/pi/artifacts</pi.deployDirectory>
<pi.main.class>RPITank</pi.main.class>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.pi4j</groupId>
<artifactId>pi4j-core</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- This plugin will generate JAR MANIFEST file inside the JAR in order to make our application easily runnable -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>${pi.main.class}</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-my-jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<!--This plugin will Transfer the executable JAR file to the Pi and runs it -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<!-- ensure the target directory exists on the Raspberry Pi -->
<sshexec host="${pi.host}" port="${pi.port}" username="${pi.user}" password="${pi.password}"
trust="true" failonerror="false" verbose="true"
command="mkdir --parents ${pi.deployDirectory}"/>
<!-- copy the JAR file to the Raspberry Pi -->
<scp
file="${project.build.directory}/${project.build.finalName}-jar-with-dependencies.jar"
todir="${pi.user}:${pi.password}@${pi.host}:${pi.deployDirectory}"
port="${pi.port}" trust="true" verbose="true" failonerror="true">
</scp>
<!-- run the JAR file on the Raspberry Pi -->
<sshexec host="${pi.host}" port="${pi.port}" username="${pi.user}"
password="${pi.password}" trust="true" failonerror="false"
verbose="true"
command="java -jar ${pi.deployDirectory}/${project.build.finalName}-jar-with-dependencies.jar"/>
</tasks>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.9.6</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
我已经在 Eclipse 上安装了 Maven,并检查了插件文件是否在我的 PC 上,并且类路径已设置(这是文件所在)
C:\Users\GJWood\.m2\repository\org\apache\maven\plugins\maven-assembly-plugin\2.2-beta-5
我也尝试过引用引用库中的 jar 文件
一切都无济于事!
【问题讨论】:
-
你是怎么称呼 Maven 的?
-
在家访问所以没有代理问题。
-
Maven 通过在 Eclipse 中运行右键 m2 选项调用
-
明确我是在 Eclipse 中运行 M2Eclipse 而不是命令行 maven
标签: java eclipse maven raspberry-pi m2eclipse