2011-12-15 144 views
0

我想建立使用Maven的詹金斯持續集成爲我寫的pom.xml包含在項目中的所有所需的JAR文件我的聚甲醛是如下Maven的:pom.xml中,無法解析包

<modelVersion>4.0.0</modelVersion> 
    <repositories> 
    <repository> 
     <id>central</id> 
     <name>My Company's Internal Repository</name> 
     <layout>default</layout> 
     <url>file:///D:/MavenRepos/</url> 
    </repository> 
    </repositories> 



<groupId>codon</groupId> 
    <artifactId>Struts2OfficeExpenses</artifactId> 
    <packaging>war</packaging> 
    <version>1.0-SNAPSHOT</version> 
    <name>Struts2Office Maven Webapp</name> 
    <url>http://maven.apache.org</url> 
    <dependencies> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>3.8.1</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>log4j</groupId> 
     <artifactId>log4j</artifactId> 
     <version>1.2.13</version> 
     <scope>main</scope> 
    </dependency> 
    <dependency> 
    <groupId>ibatis</groupId> 
    <artifactId>ibatis-common</artifactId> 
    <version>2.0</version> 
    <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.ibatis</groupId> 
     <artifactId>ibatis-sqlmap</artifactId> 
     <version>2.0</version>  
     <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>geronimo</groupId> 
     <artifactId>geronimo-management</artifactId> 
     <version>1.0</version> 

    </dependency> 
    <dependency> 
     <groupId>javax.servlet.jsp</groupId> 
     <artifactId>jsp-api</artifactId> 
     <version>2.1</version> 
     <scope>main</scope> 
     </dependency>  
    <dependency> 
     <groupId>org.apache.struts</groupId> 
     <artifactId>struts2-core</artifactId> 
     <version>2.1.8</version> 
     <scope>main</scope> 
    </dependency> 
    </dependencies> 
    <build> 
    <finalName>Struts2OfficeExpenses</finalName> 
    </build> 
</project> 

但還是我收到以下錯誤 '

[ERROR] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Compilation failure 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\FromAction.java:[9,20] package javax.servlet does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\FromAction.java:[10,20] package javax.servlet does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\FromAction.java:[11,20] package javax.servlet does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\FromAction.java:[12,25] package javax.servlet.http does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\FromAction.java:[13,25] package javax.servlet.http does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\FromAction.java:[17,31] package org.apache.struts.action does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\FromAction.java:[18,31] package org.apache.struts.action does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\FromAction.java:[19,31] package org.apache.struts.action does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\FromAction.java:[20,31] package org.apache.struts.action does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\FromAction.java:[25,32] cannot find symbol 
symbol: class Action 
public class FromAction extends Action { 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\FromAction.java:[30,31] cannot find symbol 
symbol : class ActionMapping 
location: class main.java.com.codon.user.action.FromAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\FromAction.java:[30,48] cannot find symbol 
symbol : class ActionForm 
location: class main.java.com.codon.user.action.FromAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\FromAction.java:[30,62] cannot find symbol 
symbol : class HttpServletRequest 
location: class main.java.com.codon.user.action.FromAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\FromAction.java:[30,85] cannot find symbol 
symbol : class HttpServletResponse 
location: class main.java.com.codon.user.action.FromAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\FromAction.java:[30,9] cannot find symbol 
symbol : class ActionForward 
location: class main.java.com.codon.user.action.FromAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\FromAction.java:[30,116] cannot find symbol 
symbol : class ServletException 
location: class main.java.com.codon.user.action.FromAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\UpdateAction.java:[8,20] package javax.servlet does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\UpdateAction.java:[9,20] package javax.servlet does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\UpdateAction.java:[10,20] package javax.servlet does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\UpdateAction.java:[11,25] package javax.servlet.http does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\UpdateAction.java:[12,25] package javax.servlet.http does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\UpdateAction.java:[16,31] package org.apache.struts.action does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\UpdateAction.java:[17,31] package org.apache.struts.action does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\UpdateAction.java:[18,31] package org.apache.struts.action does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\UpdateAction.java:[19,31] package org.apache.struts.action does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\UpdateAction.java:[25,34] cannot find symbol 
symbol: class Action 
public class UpdateAction extends Action { 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\UpdateAction.java:[30,31] cannot find symbol 
symbol : class ActionMapping 
location: class main.java.com.codon.user.action.UpdateAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\UpdateAction.java:[30,48] cannot find symbol 
symbol : class ActionForm 
location: class main.java.com.codon.user.action.UpdateAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\UpdateAction.java:[30,62] cannot find symbol 
symbol : class HttpServletRequest 
location: class main.java.com.codon.user.action.UpdateAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\UpdateAction.java:[30,85] cannot find symbol 
symbol : class HttpServletResponse 
location: class main.java.com.codon.user.action.UpdateAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\UpdateAction.java:[30,9] cannot find symbol 
symbol : class ActionForward 
location: class main.java.com.codon.user.action.UpdateAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\UpdateAction.java:[30,116] cannot find symbol 
symbol : class ServletException 
location: class main.java.com.codon.user.action.UpdateAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\LogoutAction.java:[3,0] package org.apache.struts.action does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\LogoutAction.java:[7,0] package javax.servlet does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\LogoutAction.java:[8,0] package javax.servlet.http does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\LogoutAction.java:[14,34] cannot find symbol 
symbol: class Action 
public class LogoutAction extends Action { 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\LogoutAction.java:[16,30] cannot find symbol 
symbol : class ActionMapping 
location: class main.java.com.codon.user.action.LogoutAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\LogoutAction.java:[17,3] cannot find symbol 
symbol : class ActionForm 
location: class main.java.com.codon.user.action.LogoutAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\LogoutAction.java:[17,19] cannot find symbol 
symbol : class HttpServletRequest 
location: class main.java.com.codon.user.action.LogoutAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\LogoutAction.java:[18,3] cannot find symbol 
symbol : class HttpServletResponse 
location: class main.java.com.codon.user.action.LogoutAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\LogoutAction.java:[16,8] cannot find symbol 
symbol : class ActionForward 
location: class main.java.com.codon.user.action.LogoutAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\LogoutAction.java:[18,39] cannot find symbol 
symbol : class ServletException 
location: class main.java.com.codon.user.action.LogoutAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\LoginAction.java:[8,20] package javax.servlet does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\LoginAction.java:[9,25] package javax.servlet.http does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\LoginAction.java:[10,25] package javax.servlet.http does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\LoginAction.java:[11,25] package javax.servlet.http does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\LoginAction.java:[15,31] package org.apache.struts.action does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\LoginAction.java:[16,31] package org.apache.struts.action does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\LoginAction.java:[17,31] package org.apache.struts.action does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\LoginAction.java:[18,31] package org.apache.struts.action does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\LoginAction.java:[24,33] cannot find symbol 
symbol: class Action 
public class LoginAction extends Action { 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\LoginAction.java:[29,31] cannot find symbol 
symbol : class ActionMapping 
location: class main.java.com.codon.user.action.LoginAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\LoginAction.java:[29,48] cannot find symbol 
symbol : class ActionForm 
location: class main.java.com.codon.user.action.LoginAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\LoginAction.java:[29,62] cannot find symbol 
symbol : class HttpServletRequest 
location: class main.java.com.codon.user.action.LoginAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\LoginAction.java:[29,85] cannot find symbol 
symbol : class HttpServletResponse 
location: class main.java.com.codon.user.action.LoginAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\LoginAction.java:[29,9] cannot find symbol 
symbol : class ActionForward 
location: class main.java.com.codon.user.action.LoginAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\LoginAction.java:[29,116] cannot find symbol 
symbol : class ServletException 
location: class main.java.com.codon.user.action.LoginAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\AddFormBean.java:[2,31] package org.apache.struts.action does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\AddFormBean.java:[3,33] cannot find symbol 
symbol: class ActionForm 
public class AddFormBean extends ActionForm{ 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\ReadToList.java:[8,20] package javax.servlet does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\ReadToList.java:[9,20] package javax.servlet does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\ReadToList.java:[10,25] package javax.servlet.http does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\ReadToList.java:[11,25] package javax.servlet.http does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\ReadToList.java:[15,31] package org.apache.struts.action does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\ReadToList.java:[16,31] package org.apache.struts.action does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\ReadToList.java:[17,31] package org.apache.struts.action does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\ReadToList.java:[18,31] package org.apache.struts.action does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\ReadToList.java:[24,32] cannot find symbol 
symbol: class Action 
public class ReadToList extends Action { 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\ReadToList.java:[29,31] cannot find symbol 
symbol : class ActionMapping 
location: class main.java.com.codon.user.action.ReadToList 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\ReadToList.java:[29,48] cannot find symbol 
symbol : class ActionForm 
location: class main.java.com.codon.user.action.ReadToList 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\ReadToList.java:[29,62] cannot find symbol 
symbol : class HttpServletRequest 
location: class main.java.com.codon.user.action.ReadToList 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\ReadToList.java:[29,85] cannot find symbol 
symbol : class HttpServletResponse 
location: class main.java.com.codon.user.action.ReadToList 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\ReadToList.java:[29,9] cannot find symbol 
symbol : class ActionForward 
location: class main.java.com.codon.user.action.ReadToList 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\ReadToList.java:[29,116] cannot find symbol 
symbol : class ServletException 
location: class main.java.com.codon.user.action.ReadToList 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\DeleteAction.java:[8,20] package javax.servlet does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\DeleteAction.java:[9,20] package javax.servlet does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\DeleteAction.java:[10,20] package javax.servlet does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\DeleteAction.java:[11,25] package javax.servlet.http does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\DeleteAction.java:[12,25] package javax.servlet.http does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\DeleteAction.java:[16,31] package org.apache.struts.action does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\DeleteAction.java:[17,31] package org.apache.struts.action does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\DeleteAction.java:[18,31] package org.apache.struts.action does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\DeleteAction.java:[19,31] package org.apache.struts.action does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\DeleteAction.java:[25,34] cannot find symbol 
symbol: class Action 
public class DeleteAction extends Action { 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\DeleteAction.java:[30,31] cannot find symbol 
symbol : class ActionMapping 
location: class main.java.com.codon.user.action.DeleteAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\DeleteAction.java:[30,48] cannot find symbol 
symbol : class ActionForm 
location: class main.java.com.codon.user.action.DeleteAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\DeleteAction.java:[30,62] cannot find symbol 
symbol : class HttpServletRequest 
location: class main.java.com.codon.user.action.DeleteAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\DeleteAction.java:[30,85] cannot find symbol 
symbol : class HttpServletResponse 
location: class main.java.com.codon.user.action.DeleteAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\DeleteAction.java:[30,9] cannot find symbol 
symbol : class ActionForward 
location: class main.java.com.codon.user.action.DeleteAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\DeleteAction.java:[30,116] cannot find symbol 
symbol : class ServletException 
location: class main.java.com.codon.user.action.DeleteAction 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\PurposeAction.java:[9,20] package javax.servlet does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\PurposeAction.java:[10,20] package javax.servlet does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\PurposeAction.java:[11,20] package javax.servlet does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\PurposeAction.java:[12,25] package javax.servlet.http does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\PurposeAction.java:[13,25] package javax.servlet.http does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\PurposeAction.java:[17,31] package org.apache.struts.action does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\PurposeAction.java:[18,31] package org.apache.struts.action does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\PurposeAction.java:[19,31] package org.apache.struts.action does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\PurposeAction.java:[20,31] package org.apache.struts.action does not exist 

D:\Projects\Jenkins-struts\src\main\java\com\codon\user\action\PurposeAction.java:[26,35] cannot find symbol 
symbol: class Action 
public class PurposeAction extends Action { 

' 請指導我.. enter code here

回答

2

我想建立使用Maven的詹金斯持續集成

採取在一步一個腳印的項目。首先嚐試使用maven在本地工作,然後在Jenkins內部嘗試。

如果您的依賴關係有問題,mvn dependency:listmvn dependency:tree可能會非常有幫助。在那裏考慮依賴關係的範圍是很重要的。

我在你的pom.xml中看到一個奇怪的<scope>main/<scope>,這可能是問題所在。 有關示波器的一些文檔,請參閱http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope

+0

感謝您的答覆沃特·我已經改變了範圍,因爲編譯解決這個問題,並嘗試在本地Maven甚至還有我得到同樣的錯誤運行 – harini 2011-12-15 12:45:45

0

我可以通過修改POM如下

<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/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>codon</groupId> 
    <artifactId>Struts2OfficeExpenses</artifactId> 
    <packaging>war</packaging> 
    <version>1.0-SNAPSHOT</version> 
    <name>Struts2Office Maven Webapp</name> 
    <url>http://maven.apache.org</url> 
    <dependencies> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>3.8.1</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>log4j</groupId> 
     <artifactId>log4j</artifactId> 
     <version>1.2.13</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>ibatis</groupId> 
     <artifactId>ibatis-common</artifactId> 
     <version>2.0</version> 
     <scope>system</scope> 
     <systemPath>D:\MavenRepos\ibatis\ibatis-common\2.0\ibatis-common-2.0.jar</systemPath> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.ibatis</groupId> 
     <artifactId>ibatis-sqlmap</artifactId> 
     <version>2.0</version>  
     <scope>system</scope> 
     <systemPath>D:\MavenRepos\org\apache\ibatis\ibatis-sqlmap\2.0\ibatis-sqlmap-2.0.jar</systemPath> 
    </dependency> 
    <dependency> 
     <groupId>geronimo</groupId> 
     <artifactId>geronimo-management</artifactId> 
     <version>1.0</version> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>servlet-api</artifactId> 
     <version>2.4</version> 
     <scope>provided</scope> 
    </dependency>  
    <dependency> 
     <groupId>org.apache.struts</groupId> 
     <artifactId>struts2-core</artifactId> 
     <version>2.1.8</version> 
     <scope>system</scope> 
     <systemPath>D:\MavenRepos\repository\org\apache\struts\struts2-core\2.1.8\struts.jar</systemPath> 
    </dependency> 
    </dependencies> 
    <build> 
    <finalName>jk-ex-3-POM</finalName> 
    </build> 
</project> 
+0

雖然它起作用,但它絕不是正確的解決方案,因爲依賴關係的路徑是「硬編碼」的。儘管你在你的問題中指定了編譯錯誤,但它之前可能有錯誤,下載相關的依賴關係。 – Raghuram 2011-12-19 11:00:05