2012-04-28 50 views
1

我創建了啓用Maven Dependency的動態Web項目。現在,當我在Eclipse中構建的JBoss AS7服務器中運行應用程序時,Maven Dependency中的jar不會複製到WAR文件的lib中,因此我得到ClassNotFoundException。在Eclipse中的服務器上運行時複製Maven依賴項Jar

我該如何解決這個問題?


編輯:

的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>EMSApplication</groupId> 
    <artifactId>EMSApplication</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>war</packaging> 
    <repositories> 
     <repository> 
      <id>googlecode</id> 
      <url>http://jqwicket.googlecode.com/svn/m2-repo/releases/</url> 
     </repository> 
    </repositories> 
    <dependencies> 
     <dependency> 
      <groupId>org.apache.wicket</groupId> 
      <artifactId>wicket-core</artifactId> 
      <version>1.5.3</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.wicket</groupId> 
      <artifactId>wicket-spring</artifactId> 
      <version>1.5.3</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.wicket</groupId> 
      <artifactId>wicket-extensions</artifactId> 
      <version>1.5.3</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.wicket</groupId> 
      <artifactId>wicket-datetime</artifactId> 
      <version>1.5.3</version> 
     </dependency> 
     <dependency> 
      <groupId>com.google.code.jqwicket</groupId> 
      <artifactId>jqwicket</artifactId> 
      <version>0.8</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-core</artifactId> 
      <version>3.1.1.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-web</artifactId> 
      <version>3.1.1.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-webmvc</artifactId> 
      <version>3.1.1.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-beans</artifactId> 
      <version>3.1.1.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>hsqldb</groupId> 
      <artifactId>hsqldb</artifactId> 
      <version>1.8.0.10</version> 
     </dependency> 
     <dependency> 
      <groupId>commons-dbcp</groupId> 
      <artifactId>commons-dbcp</artifactId> 
      <version>1.2.2</version> 
     </dependency>  
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>servlet-api</artifactId> 
      <version>2.5</version> 
     </dependency> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-log4j12</artifactId> 
      <version>1.4.2</version> 
     </dependency> 
     <dependency> 
      <groupId>log4j</groupId> 
      <artifactId>log4j</artifactId> 
      <version>1.2.14</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-orm</artifactId> 
      <version>3.1.1.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-entitymanager</artifactId> 
      <version>4.1.1.Final</version> 
     </dependency> 
     <dependency> 
      <groupId>cglib</groupId> 
      <artifactId>cglib</artifactId> 
      <version>2.2.2</version> 
     </dependency> 
    </dependencies> 
</project> 
+0

您是否將M2E和M2E用於WTP? – 2012-04-28 11:58:06

+0

你是如何定義依賴範圍的? – khmarbaise 2012-04-29 12:37:28

+0

@khmarbaise我已經在pom.xml中定義了依賴關係。這增加了圖書館的Maven Dependencies中的罐子。現在,由於我不知道如何在類路徑中自動添加這些jar,因此我手動複製這些jar並將它們放入WEB-INF的lib文件夾中,然後將這些jar放入項目屬性的classpath中。 – 2012-04-29 12:45:37

回答

1

如果你喜歡使用Maven,你必須遵循的Maven的慣例這是folder structure,你不應該嘗試去因爲你會放棄那場戰鬥。 我的建議是首先讓你的Maven構建工作,然後將其導入到IDE中,並在構建命令正常工作後繼續在那裏工作。

相關問題