简体   繁体   English

Maven项目没有建设

[英]Maven project not building

I'm trying to get Maven up and going so I can follow along and study the MongoDb for Java Developers Free course from MongoDb University online. 我正努力让Maven起来,所以我可以跟随并从MongoDb大学在线学习MongoDb for Java Developers免费课程。

I'm brand new to Maven and am having problems getting it up and going. 我是Maven的新手,我遇到了问题。 I'm getting error message: 我收到错误消息:

Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.5.0:java (default-cli) on project M101J: The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:1.5.0:java are missing or invalid -> [Help 1] 无法在项目M101J上执行目标org.codehaus.mojo:exec-maven-plugin:1.5.0:java(default-cli):目标org.codehaus.mojo的参数'mainClass':exec-maven-plugin:1.5 .0:java缺失或无效 - > [帮助1]

When I try to run mvn exec:java , I cannot figure out for the life of me what the deal is here. 当我尝试运行mvn exec:java ,我无法弄清楚我的生活是什么。 As I said, I am completely new to using (or trying to use) maven. 正如我所说,我对使用(或尝试使用)maven完全不熟悉。

Here is the pom.xml 这是pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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.mongodb</groupId>
    <artifactId>M101J</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>M101J</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project>build.sourceEncoding>UTF-8</project>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
        </dependency>
    </dependencies>

</project>

I feel as out of place as a scorpion in a nursery right now and could greatly use any help and advice to get me going. 我觉得现在作为幼儿园的蝎子不合适,可以大大使用任何帮助和建议让我去。 Many thanks to all. 非常感谢大家。

you need http://www.mojohaus.org/exec-maven-plugin/usage.html plugin 你需要http://www.mojohaus.org/exec-maven-plugin/usage.html插件

add this to your pom.xml 将其添加到您的pom.xml中

<build>
   <plugins>
      <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>exec-maven-plugin</artifactId>
         <version>1.4</version>
         <configuration>
            <mainClass>package.yourclasstorun</mainClass>
         </configuration>
      </plugin>
   </plugins>
</build>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM