我正在尝试使用maven在Jenkins持续集成中构建项目,因为我已经写了pom.xml包含了所有必需的jar文件,我的pom如下
<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
答案 0 :(得分:2)
我正在尝试使用Jenkins持续集成中的maven构建项目
一步一步。首先尝试使用maven在本地工作,然后在Jenkins内部尝试相同的操作。
如果您对依赖项有疑问,mvn dependency:list
和mvn dependency:tree
会非常有帮助。在那里考虑依赖关系的范围很重要。
我在你的pom.xml中看到一个奇怪的<scope>main/<scope>
,这可能就是问题了。
有关范围的一些文档,请参阅http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope。
答案 1 :(得分: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>