我正在使用Maven 3.0.3。我想编写一个简单的任务,将war文件从目标目录复制到Tomcat部署目录。我在哪里实现目标?我试过......
<?xml version="1.0" encoding="UTF-8"?><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>socialmediaproxy</groupId>
<artifactId>socialmediaproxy</artifactId>
<packaging>war</packaging>
<version>0.1</version>
<goal name="copy-war" description="Copies the war file to the webapps directory">
<!-- This is Ant stuff -->
<copy file="${basedir}/target/${artifactId}-${version}.war" tofile="${warDestinationDir}"/>
</goal>
但是当我跑步时
mvn copy-war -P dev
我收到此错误...
[错误]构建无法读取1个项目 - &gt; [帮助1]
[ERROR]
[错误]项目socialmediaproxy:socialmediaproxy:0.1(/Users/davea/Documents/workspace-sts-2.6.0.SR1/socialmediaproxy/pom.xml)有1个错误
[错误]格式错误的POM /Users/davea/Documents/workspace-sts-2.6.0.SR1/socialmediaproxy/pom.xml:无法识别的标签:'目标'(位置:START_TAG见过...... y-war“description =”副本war文件到webapps目录“&gt; ... @ 9:84)@ / Users/davea/Documents/workspace-sts-2.6.0.SR1/socialmediaproxy/pom.xml,第9行,第84列 - &gt; [帮助2]
有什么想法吗? - 戴夫
答案 0 :(得分:3)
pom中的目标部分不再存在,因为它来自Maven 1 ...但你定义了一个用于Maven 3的pom(模型版本4.0.0)。看看当前{{3 }}
答案 1 :(得分:0)
您可以使用ANT本身将目标目录中的内容复制到Tomcat目录
由于您要从目标目录移动文件,请在程序包阶段运行ANTRUN
插件。
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<phase>package</phase>
<configuration>
<target>
<copy file="${basedir}/target/${artifactId}-${version}.war" tofile="${warDestinationDir}"/>
</target>
</configuration>
<goals>
<goal>run</goal>
执行plase目标后,这将运行<target>
中提到的ANT任务。