---
title: "maven打包web项目为zip"
author: "junmail"
date: "2016-04-22T16:42:35Z"
tags: []
categories: ["研发管理"]
slug: "maven-web-zip"
draft: false
lastmod: "2016-04-22T16:41:28Z"
id: 2293157
url: "https://dbajun.iteye.com/blog/2293157"
---

1、pom.xml：

&lt;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"&gt;   
    &lt;id&gt;${project.version}&lt;/id&gt;   
    &lt;formats&gt;   
        &lt;format&gt;zip&lt;/format&gt;   
    &lt;/formats&gt;   
    &lt;fileSets&gt;    
        &lt;fileSet&gt;   
            &lt;directory&gt;${project.basedir}\\target\\${project.artifactId}&lt;/directory&gt;   
            &lt;outputDirectory&gt;\\${project.artifactId}&lt;/outputDirectory&gt;   
        &lt;/fileSet&gt;         
        &lt;fileSet&gt;   
            &lt;directory&gt;${project.basedir}\\src\\main&lt;/directory&gt;  
            &lt;includes&gt;   
                 &lt;include&gt;scripts&lt;/include&gt;   
                 &lt;include&gt;manual&lt;/include&gt;  
            &lt;/includes&gt;  
            &lt;outputDirectory&gt;\\&lt;/outputDirectory&gt;   
        &lt;/fileSet&gt;     
    &lt;/fileSets&gt;   
   
&lt;/assembly&gt;

 

 

2、assembly.xml:

&lt;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"&gt;   
    &lt;id&gt;${project.version}&lt;/id&gt;   
    &lt;formats&gt;   
        &lt;format&gt;zip&lt;/format&gt;   
    &lt;/formats&gt;   
    &lt;fileSets&gt;    
        &lt;fileSet&gt;   
            &lt;directory&gt;${project.basedir}\\target\\${project.artifactId}&lt;/directory&gt;   
            &lt;outputDirectory&gt;\\${project.artifactId}&lt;/outputDirectory&gt;   
        &lt;/fileSet&gt;         
        &lt;fileSet&gt;   
            &lt;directory&gt;${project.basedir}\\src\\main&lt;/directory&gt;  
            &lt;includes&gt;   
                 &lt;include&gt;scripts&lt;/include&gt;   
                 &lt;include&gt;manual&lt;/include&gt;  
            &lt;/includes&gt;  
            &lt;outputDirectory&gt;\\&lt;/outputDirectory&gt;   
        &lt;/fileSet&gt;     
    &lt;/fileSets&gt;   
   
&lt;/assembly&gt;