2012-08-31 102 views
13

我正在構建一個maven項目,但我得到的編譯失敗說,依賴項不存在。但是,我在依賴列表中看到它們。我正在使用乾淨的軟件包安裝。Maven編譯失敗,但依賴關係存在

[ERROR] \workspace\smartpharm\SmartPharm\src\main\java\com\bla\medication\service\impl\MedicationServiceImpl.java:[7,23] package org.apache.log4j does not exist 
[ERROR] \workspace\smartpharm\SmartPharm\src\main\java\com\bla\medication\service\impl\MedicationServiceImpl.java:[8,51] package org.springframework.beans.factory.annotation does not exist 
[ERROR] \workspace\smartpharm\SmartPharm\src\main\java\com\bla\medication\service\impl\MedicationServiceImpl.java:[9,37] package org.springframework.stereotype does not exist 

這裏是我的依賴列表

<properties> 
    <org.springframework.version>3.1.1.RELEASE</org.springframework.version> 
</properties> 
<dependencies> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-core</artifactId> 
     <version>${org.springframework.version}</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-beans</artifactId> 
     <version>${org.springframework.version}</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-aop</artifactId> 
     <version>${org.springframework.version}</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-jdbc</artifactId> 
     <version>${org.springframework.version}</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-webmvc</artifactId> 
     <version>${org.springframework.version}</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>commons-dbcp</groupId> 
     <artifactId>commons-dbcp</artifactId> 
     <version>1.3</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>mysql</groupId> 
     <artifactId>mysql-connector-java</artifactId> 
     <version>5.1.19</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>commons-pool</groupId> 
     <artifactId>commons-pool</artifactId> 
     <version>1.6</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>commons-codec</groupId> 
     <artifactId>commons-codec</artifactId> 
     <version>1.3</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>javax.servlet-api</artifactId> 
     <version>3.0.1</version> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>log4j</groupId> 
     <artifactId>log4j</artifactId> 
     <version>1.2.14</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>com.lexi.lexidata</groupId> 
     <artifactId>LexiData</artifactId> 
     <version>1.0</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.codehaus.jackson</groupId> 
     <artifactId>jackson-core-asl</artifactId> 
     <version>1.9.6</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-core</artifactId> 
     <version>${org.springframework.version}</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-web</artifactId> 
     <version>${org.springframework.version}</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-taglibs</artifactId> 
     <version>${org.springframework.version}</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-config</artifactId> 
     <version>${org.springframework.version}</version> 
     <exclusions> 
      <exclusion> 
       <groupId>org.springframework</groupId> 
       <artifactId>spring-context</artifactId> 
      </exclusion> 
      <exclusion> 
       <groupId>org.springframework</groupId> 
       <artifactId>spring-core</artifactId> 
      </exclusion> 
     </exclusions> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>jstl</artifactId> 
     <version>1.2</version> 
     <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-tx</artifactId> 
     <version>${org.springframework.version}</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-orm</artifactId> 
     <version>${org.springframework.version}</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.hibernate.javax.persistence</groupId> 
     <artifactId>hibernate-jpa-2.0-api</artifactId> 
     <version>1.0.1.Final</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.codehaus.jackson</groupId> 
     <artifactId>jackson-core-lgpl</artifactId> 
     <version>1.9.7</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.codehaus.jackson</groupId> 
     <artifactId>jackson-mapper-asl</artifactId> 
     <version>1.9.7</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-entitymanager</artifactId> 
     <version>4.1.4.Final</version> 
     <type>jar</type> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>cglib</groupId> 
     <artifactId>cglib</artifactId> 
     <version>2.2.2</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>4.10</version> 
     <type>jar</type> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-test</artifactId> 
     <version>${org.springframework.version}</version> 
     <type>jar</type> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>aspectj</groupId> 
     <artifactId>aspectjweaver</artifactId> 
     <version>1.5.4</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-aspects</artifactId> 
     <version>${org.springframework.version}</version> 
     <type>jar</type> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-hibernate2</artifactId> 
     <version>2.0.8</version> 
     <type>jar</type> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>javax.persistence</groupId> 
     <artifactId>persistence-api</artifactId> 
     <version>1.0</version> 
     <scope>compile</scope> 
     </dependency> 
</dependencies> 
+0

爲什麼運行時間的範圍? – Kevin

回答

31

Maven documentation

運行此範圍表明依賴不需要編譯,而是執行。它在運行時和測試 類路徑中,但不是編譯類路徑。

從pom.xml中刪除您的範圍標記或設置爲「編譯」(如juancancela說)。

希望這會幫助你

+1

您可以刪除範圍,也可以定義預期範圍。在這種情況下,編譯範圍看起來是正確的。 – juancancela