split BOMInputStream maven-shade-plugin打包可执行jar包

1.split 常用用法为String 字符串变量分隔成不同的数组,处理注意事项如下:
  (1)java 中特殊字符要进行转换如:"*^:|.",转义是要用"\\"+特殊字符;
  (2)split默认分隔字符是去掉空值,如:"5,,".split(",")长度是1,"5,,".split(",",-1)长度是3,注意使用场景。
2.BOMInputStream用于有BOM格式utf-8编码的首行文本文件,去掉bom格式可以把txt、csv文件存储为无bom格式,
读取文件用BOMInputStream去掉bom格式,否则首行的字节长度要比实际多出3个。
3.maven打包可执行jar包
  对于包含spring的项目,看了很多资料,发现用maven-shade-plugin能解决jar包的一些冲突,具体配置在build,如下:
   <build> 
  <!--指定jar包中包含的目录,有配置文件时,需要说明,否则打的包没有配置文件     这样也可以把所有的xml文件,打包到相应位置。 -->
    <resources> 
        <resource> 
            <directory>src/main/resources</directory> 
           <includes> 
                <include>**/*.properties</include> 
                <include>**/*.xml</include> 
                <include>**/*.tld</include> 
            </includes> 
            <filtering>false</filtering> 
       </resource> 
        <resource> 
            <directory>src/main/java</directory> 
           <includes> 
                <include>**/*.properties</include> 
               <include>**/*.xml</include> 
                <include>**/*.tld</include> 
            </includes> 
            <filtering>false</filtering> 
        </resource> 
    </resources> 
 <plugins>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.4.3</version>
    <executions>
     <execution>
      <phase>package</phase>
      <goals>
       <goal>shade</goal>
      </goals>
      <configuration>
       <createDependencyReducedPom>false</createDependencyReducedPom>
       <transformers>
        <transformer
         implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
         <resource>META-INF/spring.handlers</resource>
        </transformer>
        <transformer
         implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
         <resource>META-INF/spring.schemas</resource>
        </transformer>
        <transformer 
         implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> 
         <mainClass>com.chenzhou.examples.Main</mainClass> 
        </transformer> 
       </transformers>
       <filters>
        <filter>
         <artifact>*:*</artifact>
         <excludes>
          <exclude>META-INF/*.SF</exclude>
          <exclude>META-INF/*.DSA</exclude>
          <exclude>META-INF/*.RSA</exclude>
         </excludes>
        </filter>
       </filters>
      </configuration>
     </execution>
    </executions>
   </plugin>
  </plugins>

 </build>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值