需要有关 Maven 示例的帮助
我正在尝试尽快学习 Maven,因为它适合我当前的工作场所。我发现这很棒这本书几乎解释了关于 Maven 的一切。
我正在使用 eclipse 进行 java 开发,并且安装了 maven eclipse 插件,在我上面提到的书中有一个示例(可能相关也可能不相关)4.2.1。雅虎!天气 RSS。
此示例的目的是通过连接到 yahoo 天气 RSS 服务器并从中获取适当的数据来说明 Maven 如何以稍微复杂的方式工作。
我挣扎的是下面这一行,我设法从cmd执行它(我使用的是win-7)
mvn exec:java -Dexec.mainClass=org.sonatype.mavenbook.weather.Main
当我使用文本编辑器和cmd时,首先编辑文件,然后使用maven执行命令,我所做的一切都与本书一切运行完美,但我们使用 Eclipse,所以我想学习如何使用 Eclipse 做同样的事情。
我如何从日食中做到这一点?
这是我尝试运行的图像:
alt text http://postavi.com/hosted/bc0de2440ba2b5017a92672c721dcca1 .gif
所以我进入下一个屏幕:
alt text http://postavi.com/ Hosted/5c79320f64e850879d49823c4a6e2ecb.gif
我运行它并收到此错误:
Version: 1.1.1
Mojo: exec
brought in via: Direct invocation
While building project:
Group-Id: org.sonatype.mavenbook.custom
Artifact-Id: weather
Version: 0.0.1-SNAPSHOT
From file: C:\OPR-CS\weather\pom.xml
Missing parameters include:
executable
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run with the -e flag
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILED
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Tue Feb 02 14:47:04 CET 2010
[INFO] Final Memory: 1M/7M
[INFO] ------------------------------------------------------------------------
我假设我没有传递适当的参数,如上面的错误中所述。
-Dexec.mainClass=org.sonatype.mavenbook.weather.Main
上面这一行。因为我不知道怎么做。这是 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.sonatype.mavenbook.custom</groupId>
<artifactId>weather</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>weather</name>
<url>http://maven.apache.org</url>
<licenses>
<license>
<name>Apache 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>
<organization>
<name>ORIGIGI</name>
<url>http://www.devs.com</url>
</organization>
<developers>
<developer>
<id>emco</id>
<name>Myself and I</name>
<email>[email protected]</email>
<url>http://www.devs.com</url>
<organization>ORIGIGI</organization>
<organizationUrl>http://www.devs.com</organizationUrl>
<roles>
<role>developer</role>
</roles>
<timezone>-6</timezone>
</developer>
</developers>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.5</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
有人可以帮助我吗?谢谢
I'm trying to learn maven ASAP as its required for my current work place. I found this great book which pretty much explains everything about maven.
I'm using eclipse for java development and I installed maven eclipse plugin, in the book I mentioned above there is example(which may or may not be relevant) 4.2.1. Yahoo! Weather RSS.
Purpose of this example is to ilustrate how maven works in a slightly more complex way, by connecting to the yahoo weather rss server and getting the appropriate data from it.
With what I struggle is this line below,I manage to execute it from cmd(I'm using win-7)
mvn exec:java -Dexec.mainClass=org.sonatype.mavenbook.weather.Main
When I use text editor and cmd, first to edit files and second to perform commands with maven I do everything as in the book everything runs perfectly, but we work with eclipse so I'd like to learn how to do the same with eclipse.
How do I do this from eclipse?
Here is the image of what I try to run :
alt text http://postavi.com/hosted/bc0de2440ba2b5017a92672c721dcca1.gif
So I get to the next screen :
alt text http://postavi.com/hosted/5c79320f64e850879d49823c4a6e2ecb.gif
I run it and I get this error :
Version: 1.1.1
Mojo: exec
brought in via: Direct invocation
While building project:
Group-Id: org.sonatype.mavenbook.custom
Artifact-Id: weather
Version: 0.0.1-SNAPSHOT
From file: C:\OPR-CS\weather\pom.xml
Missing parameters include:
executable
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run with the -e flag
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILED
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Tue Feb 02 14:47:04 CET 2010
[INFO] Final Memory: 1M/7M
[INFO] ------------------------------------------------------------------------
I assume I didn't pass the appropriate parameteres as it says in error above.
-Dexec.mainClass=org.sonatype.mavenbook.weather.Main
This line above. Because I don't know how. Here is the pom.xml file, same as in book slightly adjusted here it is:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.sonatype.mavenbook.custom</groupId>
<artifactId>weather</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>weather</name>
<url>http://maven.apache.org</url>
<licenses>
<license>
<name>Apache 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>
<organization>
<name>ORIGIGI</name>
<url>http://www.devs.com</url>
</organization>
<developers>
<developer>
<id>emco</id>
<name>Myself and I</name>
<email>[email protected]</email>
<url>http://www.devs.com</url>
<organization>ORIGIGI</organization>
<organizationUrl>http://www.devs.com</organizationUrl>
<roles>
<role>developer</role>
</roles>
<timezone>-6</timezone>
</developer>
</developers>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.5</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Can anyone help me? Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在调用
exec:exec
而不是exec:java
。目标部分应为
exec:java
,并位于 JRE 选项卡和-Dexec.mainClass=...
参数中。You're invoking
exec:exec
instead ofexec:java
.The goals section should be
exec:java
, and in the JRE tab and the-Dexec.mainClass=...
argument.