2013-08-19 130 views
1

我正在用hibernate和maven製作一個web應用程序,我無法下載hibernate依賴關係。下載休眠依賴關係

這是我的依賴行:

<dependencies> 
     <!-- JDBC driver --> 
     <dependency> 
      <groupId>${jdbcDriver.groupId}</groupId> 
      <artifactId>${jdbcDriver.artifactId}</artifactId> 
      <version>${jdbcDriver.version}</version> 
      <scope>test</scope> 
     </dependency> 
     <!-- SLF4J (required by Hibernate) --> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-simple</artifactId> 
      <version>${slf4j.version}</version> 
      <scope>runtime</scope> 
     </dependency> 
     <!-- Javassist (required by Hibernate) --> 
     <dependency> 
      <groupId>org.javassist</groupId> 
      <artifactId>javassist</artifactId> 
      <version>${javassist.version}</version> 
      <scope>runtime</scope> 
     </dependency> 
     <!-- CGLIB (required by Spring) --> 
     <dependency> 
      <groupId>cglib</groupId> 
      <artifactId>cglib-nodep</artifactId> 
      <version>${cglib.version}</version> 
      <scope>runtime</scope> 
     </dependency> 
     <!-- Hibernate --> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-core</artifactId> 
      <version>${hibernate.version}</version> 
     </dependency> 
     <!-- JUnit --> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>${junit.version}</version> 
      <scope>test</scope> 
     </dependency> 
     <!-- Spring --> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-orm</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-test</artifactId> 
      <version>${spring.version}</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-web</artifactId> 
      <version>${spring.version}</version> 
      <scope>runtime</scope> 
     </dependency> 
     <!-- Servlet API --> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>servlet-api</artifactId> 
      <version>${servletApi.version}</version> 
      <scope>provided</scope> 
     </dependency> 
     <!-- Tapestry --> 
     <dependency> 
      <groupId>org.apache.tapestry</groupId> 
      <artifactId>tapestry-core</artifactId> 
      <version>${tapestry.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.tapestry</groupId> 
      <artifactId>tapestry-spring</artifactId> 
      <version>${tapestry.version}</version> 
     </dependency> 


    </dependencies> 

我試圖MVN蝕:elicpse然後MVN安裝-U但我仍然得到以下錯誤的,其中包括休眠註釋每行代碼

[ERROR] \Users\Radorf\workspace\pfcswim\src\main\java\e\v\v\pfcswim\model\user\User.java:[5,24] error: package javax.persistence does not exist

回答

0

你明顯錯過了JPA註釋。我似乎記得

<dependency> 
    <groupId>org.hibernate</groupId> 
    <artifactId>hibernate-annotations</artifactId> 
    <version>${hibernate.version}</version> 
</dependency> 

javax.persistence:persistence-api作爲傳遞依賴。我猜你錯過了那個?

當然,你可以搶JPA神器直接和:

<dependency> 
    <groupId>javax.persistence</groupId> 
    <artifactId>persistence-api</artifactId> 
    <version>1.0</version> 
</dependency> 

,或者找你嘗試了JPA2:

<dependency> 
    <groupId>org.hibernate.javax.persistence</groupId> 
    <artifactId>hibernate-jpa-2.0-api</artifactId> 
    <version>1.0.1.Final</version> 
</dependency> 

乾杯,

+0

我試過了,但它不工作。 反正謝謝你。 – Radorf

+0

你確定你獲得了依賴嗎?檢入'〜/ .m2'。另請參閱我編輯的答案。你想要什麼Hibernate版本? –

+0

我試過你發佈的內容,但仍然無法正常工作。我檢查了/.m2目錄,我猜這個jar應該在m2 \ repository \ org中,但是我不能在那裏找到它,所以無論什麼原因,我都無法下載它。 – Radorf