我刚跟着这个question并修改了我的pom来创建不同的war文件。这是原始配置
<build>
<finalName>Cambellton</finalName>
<plugins>
<!-- Run with Jetty -->
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.10</version>
<configuration>
<scanIntervalSeconds>5</scanIntervalSeconds>
<stopKey>foo</stopKey>
<stopPort>9999</stopPort>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Compile java -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<!-- Build war -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<version>2.1.1</version>
</plugin>
<!-- Pack zips -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>webapp</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>Cambellton{packname}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/webapp.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
这是Modified(想要创建Cambellton.war)
> [INFO]
[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ LabSystem ---
[INFO] Packaging webapp
[INFO] Assembling webapp [LabSystem] in [F:\MyDocuments\Java\ZK7LabSystem\LabSystem\LabSystem\target\Cambellton]
[INFO] Processing war project
[INFO] Copying webapp resources [F:\MyDocuments\Java\ZK7LabSystem\LabSystem\LabSystem\src\main\webapp]
[INFO] Webapp assembled in [4554 msecs]
[INFO] Building war: F:\MyDocuments\Java\ZK7LabSystem\LabSystem\LabSystem\target\Cambellton.war
[WARNING] Warning: selected war files include a WEB-INF/web.xml which will be ignored
(webxml attribute is missing from war task, or ignoreWebxml attribute is specified as 'true')
[INFO]
[INFO] --- maven-assembly-plugin:2.2:single (webapp) @ LabSystem ---
[INFO] Reading assembly descriptor: src/main/assembly/webapp.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.543s
[INFO] Finished at: Thu Dec 17 11:29:29 IST 2015
[INFO] Final Memory: 16M/348M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2:single (webapp) on project LabSystem: Failed to create assembly: Error adding file to archive: F:\MyDocuments\Java\ZK7LabSystem\LabSystem\LabSystem\target\LabSystem.war isn't a file. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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 read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
尝试构建时,会出错,但会创建war文件。我认为在尝试创建zip文件时会出现问题。这是错误消息
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>webapp</id>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.basedir}/src/main/java</directory>
<outputDirectory>/${project.artifactId}/src</outputDirectory>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/main/webapp</directory>
<outputDirectory>/${project.artifactId}/WebContent</outputDirectory>
</fileSet>
</fileSets>
<files>
<file>
<source>${project.build.directory}/${project.artifactId}.war</source>
<outputDirectory>/</outputDirectory>
</file>
</files>
</assembly>
编辑1
这是webapp.xml
<build>
<finalName>$Cambellton</finalName>
<plugins>
<!-- Run with Jetty -->
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.10</version>
<configuration>
<scanIntervalSeconds>5</scanIntervalSeconds>
<stopKey>foo</stopKey>
<stopPort>9999</stopPort>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Compile java -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<!-- Build war -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<version>2.3</version>
</plugin>
<!-- Pack zips -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>webapp</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>Cambellton${packname}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/webapp.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
编辑2: 还添加了$符号,但仍然给出了同样的错误 正如
<?php
date_default_timezone_set('Asia/Kolkata');
$timestamp = time();
$date_time = date("d-m-Y (D) H:i:s", $timestamp);
echo "Current date and local time on this server is $date_time";
?>
答案 0 :(得分:1)
在Maven Assembly Plugin配置中,检查
<finalName>Cambellton{packname}</finalName>
{packname}
未被识别为属性,因为缺少$
前缀。假设您将packname
定义为pom中的属性。
在原始配置中,它是
<finalName>LabSystem${packname}</finalName>
同时检查src/main/assembly/webapp.xml
文件的一致性,该文件可能包含任何或指定的生成的war文件,如下例所示:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>zip</id>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
<includes>
<include>*.war</include>
</includes>
<useDefaultExcludes>true</useDefaultExcludes>
</fileSet>
</fileSets>
</assembly>
<强>更新强>
根据您的最新编辑(添加装配配置),我看到了一些可以改进的事情以及潜在的错误原因:
Cambellton
,因此您还应使其与此更改保持一致(${project.build.directory}/Cambellton.war
而不是{{ 1}})。这很可能导致构建错误${project.build.directory}/${project.artifactId}.war
我会将其替换为/${project.artifactId}/src
(${project.basedir}/src
输出目录相同)