2011-09-13 121 views
1

嗨我试图在我的台式机上安装Hibernate v4.0.0.CR2,它需要Maven来运行。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文件是在bin目录中Maven的:

<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的。

任何想法,我哪里出错了?

谢谢!

回答

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

谢谢!正是我需要的 – Nacht