Maven常用插件集合

在这里记录常用的插件,以备用时可快速查询,会持续更新

1. maven-compile-plugin

    官方介绍 http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-using-different-jdk.html

    在pom.xml文件中默认编译级别是1.5,如果需改成1.6,可以在pom.xml中增加如下配置

<plugin>

    <artifactId>maven-compiler-plugin</artifactId>
    <extensions>true</extensions> 
    <configuration>
        <source>1.6</source>
        <target>1.6</target>
    </configuration>
</plugin>


extensions表示继续默认的配置,这里只是修改了编译jdk为1.6


2. maven-bundle-plugin
    官方介绍 http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <extensions>true</extensions>
    <configuration>
         <instructions>
                <Export-Package>com.my.company.api</Export-Package>
                <Private-Package>com.my.company.*</Private-Package>
                <Bundle-Activator>com.my.company.Activator</Bundle-Activator>
          </instructions>
    </configuration>
</plugin>


3. maven-dependency-plugin

      官方介绍 http://maven.apache.org/plugins/maven-dependency-plugin/

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.8</version>
        <executions>
          <execution>
            <id>copy-dependencies</id>
            <phase>package</phase>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/lib</outputDirectory>
              <overWriteReleases>false</overWriteReleases>
              <overWriteSnapshots>true</overWriteSnapshots>
	      <overWriteIfNewer>true<overWriterIfNewer>
              <excludeArtifactIds>servlet-api<excludeArtifactIds>
            </configuration>
          </execution>
        </executions>
      </plugin>
   这个配置可以把所有的依赖拷贝到lib目录下,通过maven-jar-plugin就可以将lib下面的jar包打到最终的jar里面
      
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <executions>
          <execution>
            <id>jar</id>
            <phase>package</phase>
            <goals>
              <goal>jar</goal>
            </goals>
            <configuration>
              <classesDirectory>${project.build.directory}/lib</classesDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
4. maven-war-plugin
   官方介绍:http://maven.apache.org/plugins/maven-war-plugin/
   
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.3</version>
        <configuration>
          <webResources>
            <resource>
              <!-- this is relative to the pom.xml directory -->
              <directory>resource2</directory><!--打包时包含这个目录的内容-->
              <excludes> <!--排除一些目录-->
                <exclude>**/properties</exclude>
              </excludes>
</resource>  
          </webResources>        
        </configuration>      
     </plugin>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值