2011-05-22 173 views
3

我在Eclipse(Helios)中有一個使用Maven pom.xml的項目。 我的項目是一個將使用Hibernate,MySQL的Web應用程序。POM依賴不起作用(Eclipse,Maven,POM)

但是,我無法得到pom.xml的權利。我對maven很陌生,不能相信建立依賴關係是如此艱難(其他人有類似的expierience /或者我是愚蠢的)。

我的pom.xml的是在這裏:

<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>MyProj1</groupId> 
    <artifactId>MyProj1</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 

    <repositories> 
    <repository> 
     <id>jboss-public-repository-group</id> 
     <name>JBoss Public Repository Group</name> 
     <url>http://repository.jboss.org/nexus/content/groups/public/</url> 
     <layout>default</layout> 
     <releases> 
     <enabled>true</enabled> 
     <updatePolicy>never</updatePolicy> 
     </releases> 
     <snapshots> 
     <enabled>true</enabled> 
     <updatePolicy>never</updatePolicy> 
     </snapshots> 
    </repository> 

    <repository> 
     <id>Scala Tools</id> 
     <name>Scala Tools</name> 
     <url>http://scala-tools.org/repo-releases/</url> 
     <layout>default</layout> 
     <releases> 
     <enabled>true</enabled> 
     <updatePolicy>never</updatePolicy> 
     </releases> 
     <snapshots> 
     <enabled>true</enabled> 
     <updatePolicy>never</updatePolicy> 
     </snapshots> 
    </repository> 

    </repositories> 

    <dependencies> 

    <dependency> 
     <groupId>commons-logging</groupId> 
     <artifactId>commons-logging</artifactId> 
     <version>1.1.1</version> 
    </dependency> 
    <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-entitymanager</artifactId> 
      <version>3.6.4.Final</version> 
     </dependency>  
      <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-core</artifactId> 
      <version>3.6.4.Final</version> 
     </dependency> 
     <!-- 
     <dependency>   
      <groupId>org.hibernate</groupId>   
      <artifactId>hibernate-annotations</artifactId>   
      <version>3.6.4.Final</version>  
     </dependency> 
     --> 
     <dependency> 
      <groupId>antlr</groupId> 
      <artifactId>antlr</artifactId> 
      <version>2.7.6-brew</version> 
     </dependency>    
     <dependency> 
      <groupId>dom4j</groupId> 
      <artifactId>dom4j</artifactId> 
      <version>1.6.1-jboss</version> 
     </dependency>      
     <dependency> 
      <groupId>asm</groupId> 
      <artifactId>asm</artifactId> 
      <version>1.4.3</version> 
     </dependency> 
     <dependency> 
      <groupId>cglib</groupId> 
      <artifactId>cglib</artifactId> 
      <version>2.1.1</version> 
     </dependency>  

     <dependency> 
      <groupId>mysql</groupId> 
      <artifactId>mysql-connector-java</artifactId> 
      <version>5.1.16</version> 
     </dependency> 
    </dependencies> 
</project> 

我得到的錯誤是:

Missing artifact commons-logging:commons-logging:jar:1.1.1:compile 

Missing artifact org.hibernate:hibernate-entitymanager:jar:3.6.4.Final:compile 

Missing artifact javassist:javassist:jar:3.12.0.GA:compile 

Missing artifact org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.0.Final:compile 

Missing artifact org.slf4j:slf4j-api:jar:1.6.1:compile 

Missing artifact org.hibernate:hibernate-core:jar:3.6.4.Final:compile 

Missing artifact commons-collections:commons-collections:jar:3.1:compile 

Missing artifact org.hibernate:hibernate-commons-annotations:jar:3.2.0.Final:compile 

Missing artifact javax.transaction:jta:jar:1.1:compile 

Missing artifact antlr:antlr:jar:2.7.6-brew:compile 

Missing artifact dom4j:dom4j:jar:1.6.1-jboss:compile 

Missing artifact xml-apis:xml-apis:jar:1.0.b2:compile 

Missing artifact asm:asm:jar:1.4.3:compile 

Missing artifact cglib:cglib:jar:2.1.1:compile 

--- 

所有上述錯誤消失,如果我從pom.xml文件刪除mysql的依賴。 我完全困惑爲什麼mysql應該依賴於這些。

是不是Maven應該自動解決這些依賴關係?畢竟這不是使用Maven的全部想法。

請專家指導我正確的方向。

回答