首页 > 代码库 > maven 几个插件的使用

maven 几个插件的使用

1.  compile 

 <plugin>               <artifactId>maven-compiler-plugin</artifactId>               <configuration>                   <source>1.6</source>                   <target>1.6</target>                   <encoding>UTF-8</encoding>                   <compilerArguments>                    <extdirs>lib/</extdirs>   //  三方jar 包编译配置                 </compilerArguments>               </configuration>             </plugin>

  

2.  依赖打包

<plugin>            <groupId>org.apache.maven.plugins</groupId>            <artifactId>maven-dependency-plugin</artifactId>            <executions>                <execution>                    <id>copy-dependencies</id>                    <phase>prepare-package</phase>                    <goals>                        <goal>copy-dependencies</goal>                    </goals>                    <configuration>                        <outputDirectory>${project.build.directory}/lib</outputDirectory>                        <overWriteReleases>false</overWriteReleases>                        <overWriteSnapshots>false</overWriteSnapshots>                        <overWriteIfNewer>true</overWriteIfNewer>                    </configuration>                </execution>            </executions>        </plugin>

  

3. 可执行jar 包

    

 <build>          <finalName>image</finalName>          <plugins>              <plugin>                  <groupId>org.apache.maven.plugins</groupId>                  <artifactId>maven-jar-plugin</artifactId>                  <version>2.4</version>                  <configuration>                      <archive>                          <manifest>                              <addClasspath>true</addClasspath>                              <classpathPrefix>lib/</classpathPrefix>                              <mainClass>image_handle.App</mainClass>                          </manifest>                      </archive>                  </configuration>              </plugin>          </plugins>      </build>

  

4.  另一个包含依赖

     

<plugins>              <plugin>                  <artifactId>maven-assembly-plugin</artifactId>                  <configuration>                      <archive>                          <manifest>                              <mainClass>com.allen.capturewebdata.Main</mainClass>                          </manifest>                      </archive>                      <descriptorRefs>                          <descriptorRef>jar-with-dependencies</descriptorRef>                      </descriptorRefs>                  </configuration>              </plugin>          </plugins>

  

maven 几个插件的使用