Maven构建错误

时间:2011-09-13 01:01:18

标签: hibernate maven-3

您好我正在尝试在台式机上安装Hibernate v4.0.0.CR2,它需要Maven才能运行。

我为Maven设置了所需的环境变量,并尝试从命令行构建maven。当我从Maven中的bin目录(在我的桌面上)的命令提示符中运行命令'mvn 3.0.3'时,我收到错误:

 D:\Documents and Settings\user\Desktop\apache-maven-3.0.3\bin>mvn
 3.0.3 [INFO] Scanning for projects... [ERROR] The build could not read
 1 project -> [Help 1] [ERROR] [ERROR]   The project
 org.hibernate.tutorials:hibernate-tutorial:1.0.0-SNAPSHOT
 (D:\Documents and
 Settings\user\Desktop\apache-maven-3.0.3\bin\pom.xml) has 4  errors
 [ERROR]     'dependencies.dependency.version' for
 org.hibernate:hibernate-core:j ar is missing. @ line 18, column 21
 [ERROR]     'dependencies.dependency.version' for
 javax.servlet:servlet-api:jar is missing. @ line 24, column 21 [ERROR]
 'dependencies.dependency.version' for org.slf4j:slf4j-simple:jar is
 missing. @ line 30, column 21 [ERROR]    
 'dependencies.dependency.version' for javassist:javassist:jar is mis
 sing. @ line 36, column 21 [ERROR] [ERROR] To see the full stack trace
 of the errors, re-run Maven with the -e swit ch. [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 rea d
 the following articles: [ERROR] [Help 1]
 http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildin
 gException D:\Documents and
 Settings\user\Desktop\apache-maven-3.0.3\bin>

我的POM.xml文件位于Maven的bin目录中:

 <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>org.hibernate.tutorials</groupId>
     <artifactId>hibernate-tutorial</artifactId>
     <version>1.0.0-SNAPSHOT</version>
     <name>First Hibernate Tutorial</name>

     <build>
          <!-- we dont want the version to be part of the generated war
 file name -->
          <finalName>${artifactId}</finalName>
     </build>

     <dependencies>
         <dependency>
             <groupId>org.hibernate</groupId>
             <artifactId>hibernate-core</artifactId>
         </dependency>

         <!-- Because this is a web app, we also have a dependency on
 the servlet api. -->
         <dependency>
             <groupId>javax.servlet</groupId>
             <artifactId>servlet-api</artifactId>
         </dependency>

         <!-- Hibernate uses slf4j for logging, for our purposes here
 use the simple backend -->
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-simple</artifactId>
         </dependency>

         <!-- Hibernate gives you a choice of bytecode providers
 between cglib and javassist -->
         <dependency>
             <groupId>javassist</groupId>
             <artifactId>javassist</artifactId>
         </dependency>
     </dependencies> </project>

我正在关注网站上的Hibernate教程,以了解Hibernate在工作中的使用情况,但我偶然发现了这个问题。

我出错的任何想法?

谢谢!

1 个答案:

答案 0 :(得分:3)

  1. Hibernate不需要Maven。 Maven只是一个构建工具。
  2. 运行Maven的命令是mvn,而不是mvn 3.0.3
  3. 正如错误告诉您的那样,您必须为每个依赖项提供一个版本。换句话说,与<groupId><artifactId>一起,您必须指定<version>元素。