使用maven打包jar可能war

使用maven打包jar或者war
如何把配置文件打包到jar中 http://blog.csdn.net/ciedecem/article/details/10382275
maven打包总结 http://blog.csdn.net/fireofjava/article/details/14447325
maven打jar包 http://hy90171.iteye.com/blog/1916293
使用maven打出独立应用程序的jar包 http://pipilu.iteye.com/blog/399816
maven生成war包的两种方式http://touchfu.iteye.com/blog/545708
Maven 是怎样创建War 包? http://my.oschina.net/u/939534/blog/173863


1. 打包jar时,想排除所有的resource文件
<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <classifier>lib</classifier>
                            <excludes>
                                <exclude>*Main*</exclude>
                            </excludes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>



2. 打war包时排除resource
<build>   
  <plugins>
   <plugin>   
    <groupId>org.apache.maven.plugins</groupId>   
    <artifactId>maven-war-plugin</artifactId>   
    <version>2.0.2</version>   
    <configuration>   
     <warSourceExcludes>src/main/resources/**</warSourceExcludes>   
    </configuration>   
   </plugin>   
  </plugins>   
 </build>


注意:pom.xml定义的一些属性,是可以被使用到applicationContext.xml里面的,
比如:pom.xml存在<hibernate.dialect>org.hibernate.dialect.SQLServerDialect</hibernate.dialect>,然后jdbc.properties存在hibernate.dialect=${hibernate.dialect},applicationContext.xml存在<prop key="hibernate.dialect">${hibernate.dialect}</prop>,那么打包得到的war,applicationContext.xml会变为:<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>