繁体   English   中英

尝试使用mvn软件包时出现mvn软件包错误

[英]mvn package error when trying mvn package

我已经从svn中签出了一个项目。 我正在尝试使用Maven构建项目。

使用mvn编译可以很好地构建它。

当我尝试使用命令mvn软件包时,出现以下错误。

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.737 s
[INFO] Finished at: 2014-12-22T19:30:54-06:00
[INFO] Final Memory: 12M/155M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war
 (default-war) on project usermanager: Error assembling WAR: webxml attribute is
 required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help
 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE

我发现这是因为没有将web.xml提供给pom.xml。

我已经尝试了栈中所有答案中给出的所有方法。 但是似乎没有任何作用

这是我的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/maven-v4_0_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/maven-v4_0_0.xsd http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.joseph</groupId>
    <artifactId>usermanager</artifactId>
    <packaging>war</packaging>
    <name>User Manager</name>
    <version>1.0</version>
    <description>
        The User Manager is an administration interface for Intranet Users, Groups, Applications, and Permissions.
    </description>
    <url>http://projects.joseph.com/usermanager</url>
    <inceptionYear>2006</inceptionYear>
    <issueManagement>
        <system>Bug Tracker</system>
        <url>http://bugtracker.joseph.com</url>
    </issueManagement>
    <developers>
        <developer>
            <id>lforehand</id>
            <name>Luke Forehand</name>
            <email>lforehand@parts-unltd.com</email>
            <organization>Joseph Corporation</organization>
            <organizationUrl>http://wiki.josephnet.com</organizationUrl>
            <roles>
                <role>Java Developer</role>
            </roles>
        </developer>
    </developers>
    <build>
        <directory>build</directory>
        <testOutputDirectory>build/test-classes</testOutputDirectory>
        <outputDirectory>build/classes</outputDirectory>
        <sourceDirectory>WEB-INF/src</sourceDirectory>
        <testSourceDirectory>test</testSourceDirectory>
        <resources>
            <resource>
                <directory>deploy</directory>
                <includes>
                    <include>**/*.properties</include>
                </includes>
            </resource>
        </resources>
        <testResources>
            <testResource>
                <directory>deploy</directory>
                <includes>
                    <include>**/*.properties</include>
                </includes>
            </testResource>
        </testResources>
    </build>
    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>2.1</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.2</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.1</version>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jxr-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>changelog-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>taglist-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </reporting>
    <distributionManagement>
        <site>
            <url>scp://josephnet.com/var/www/projects.joseph.com/usermanager</url>
        </site>
        <repository>
            <id>internal</id>
            <name>Joseph Upload Repository</name>
            <url>file:////snap01/Backup/maven-repo</url>
        </repository>
    </distributionManagement>
    <scm>
        <connection>scm:svn:http://toolbox01/usermanager.josephnet.com/</connection>
        <developerConnection>svn://toolbox01/usermanager.josephnet.com/</developerConnection>
        <url>http://toolbox01/usermanager.josephnet.com/</url>
    </scm>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.joseph</groupId>
            <artifactId>joseph-user-common</artifactId>
            <version>1.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>struts</groupId>
            <artifactId>struts</artifactId>
            <version>1.2.9</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.1.2</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>1.1.2</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.4</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.9</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-validator</groupId>
            <artifactId>commons-validator</artifactId>
            <version>1.3</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-digester</groupId>
            <artifactId>commons-digester</artifactId>
            <version>1.6</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.0.4</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.7.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-dao</artifactId>
            <version>1.2.6</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>1.2.6</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>1.2.6</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>1.2.6</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>1.2.6</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>1.2.6</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
</project>

默认情况下,此插件要求在构建路径中存在WEB-INF / web.xml。 如果您没有,请设置以下属性以避免错误

failOnMissingWebXml = false  //case sensitive, default value is true

<project>
...
 <build>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.5</version>  // Must use 2.1-alpha-2+
    <configuration>
        <failOnMissingWebXml>false</failOnMissingWebXml>
    </configuration>
  </plugin>
 </build>
</project>

创建虚拟的web.xml文件不是解决此问题的干净方法。 apache文档中提供了更多配置

日志很清楚

我猜你的pom.xml配置是这样的:

<packaging>war</packaging>

以某种方式打包的War必须具有WEB-INF / web.xml文件,您必须在webapp目录中手动添加WEB-INF目录和web.xml文件。

我有相同的问题,并通过修改pom.xml进行了修复

<build>
    <finalName>AngularSpringApp</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
    </plugins>
</build>

您可以参考http://www.javaroots.com/2014/01/webxml-attribute-is-required-error-in.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM