Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 需要maven示例的帮助吗_Java_Eclipse_Maven 2_Eclipse Plugin_Maven Plugin - Fatal编程技术网

Java 需要maven示例的帮助吗

Java 需要maven示例的帮助吗,java,eclipse,maven-2,eclipse-plugin,maven-plugin,Java,Eclipse,Maven 2,Eclipse Plugin,Maven Plugin,我正试图尽快学习maven,因为它是我目前工作场所所需要的。我发现了一本很棒的书,它几乎解释了maven的一切 我使用eclipse进行java开发,并安装了maven eclipse插件,在我上面提到的书中有一个示例(可能相关,也可能无关)4.2.1。雅虎!天气RSS 本例的目的是通过连接到yahoo weather rss服务器并从中获取适当的数据,说明maven是如何以稍微复杂一点的方式工作的 下面这一行是我的难题,我设法从cmd执行它(我使用的是win-7) 当我使用文本编辑器和cmd时

我正试图尽快学习maven,因为它是我目前工作场所所需要的。我发现了一本很棒的书,它几乎解释了maven的一切

我使用eclipse进行java开发,并安装了maven eclipse插件,在我上面提到的书中有一个示例(可能相关,也可能无关)4.2.1。雅虎!天气RSS

本例的目的是通过连接到yahoo weather rss服务器并从中获取适当的数据,说明maven是如何以稍微复杂一点的方式工作的

下面这一行是我的难题,我设法从cmd执行它(我使用的是win-7)

当我使用文本编辑器和cmd时,首先是编辑文件,其次是使用maven执行命令,我做的一切都和书中的一样,一切都运行得很好,但是我们使用eclipse,所以我想学习如何使用eclipse做同样的事情

如何从eclipse中执行此操作

以下是我尝试运行的图像:

因此,我进入下一个屏幕:

我运行了它,得到了以下错误:

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] ------------------------------------------------------------------------
这条线在上面。因为我不知道怎么做。这是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>devs@devs.com</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>

4.0.0
org.sonatype.mavenbook.custom
天气
罐子
0.0.1-快照
天气
http://maven.apache.org
阿帕奇2
http://www.apache.org/licenses/LICENSE-2.0.txt
回购
业务友好的OSS许可证
奥利吉
http://www.devs.com
埃姆科
我和我
devs@devs.com
http://www.devs.com
奥利吉
http://www.devs.com
开发商
-6
朱尼特
朱尼特
3.8.1
测试
log4j
log4j
1.2.14
dom4j
dom4j
1.6.1
杰克森
杰克森
1.1.1
速度
速度
1.5
maven编译器插件
1.5
1.5

有人能帮我吗?谢谢

您调用的是
exec:exec
,而不是
exec:java


目标部分应该是
exec:java
,在JRE选项卡和
-Dexec.mainClass=…
参数中。

@Robert Munteanu我现在得到这个错误
无效的mojo或生命周期阶段:org.codehaus.mojo:exec maven插件:1.1.1:exec:java原始错误消息是:无效任务“org.codehaus.mojo:exec maven插件:1.1.1:exec:java”:您必须指定有效的生命周期阶段,或者是plugin:goal或pluginGroupId:pluginarifactid:pluginreversion:goal格式的目标
现在构建再次失败,但这次我得到了这个错误
原因:在执行Java类时发生了异常。null
@Robert Munteanu,这是否意味着我的/books代码中的某个地方有错误?是的,这是错误的。。这本书的作者犯了错误。。将int与string混淆。。谢谢..它是-Dexec.mainClass=不是-DmainClass。。提问者至少在这方面是正确的。
-Dexec.mainClass=org.sonatype.mavenbook.weather.Main 
<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>devs@devs.com</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>