2011-09-13 152 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