maven打war包后,excel文件乱码,其余纯文本文件都正常

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了maven打war包后,excel文件乱码,其余纯文本文件都正常相关的知识,希望对你有一定的参考价值。

maven打war包后,excel文件乱码,其余纯文本文件都正常,请问怎么解决?

参考技术A <plugin>
<!-- war插件 -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warName>maternal</warName>
<failOnMissingWebXml>false</failOnMissingWebXml>
<filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
<!--<excludes> <!– 排除文件,不包含子目录,对WEB-INF目录无效 –>
<exclued>**/EOIE8-WindowsXP-x86.exe</exclued>
</excludes>-->
<webResources>
<resource>
<filtering>true</filtering>
<directory>$project.basedir/WebRoot</directory>
<excludes>
<exclude>**/*.jar</exclude>
<exclued>**/EOIE8-WindowsXP-x86.exe</exclued>
</excludes>
<targetPath>/</targetPath>
</resource>
</webResources>
<nonFilteredFileExtensions>
<nonFilteredFileExtension>xls</nonFilteredFileExtension>
<nonFilteredFileExtension>xlsx</nonFilteredFileExtension>
</nonFilteredFileExtensions>
<!--<includeEmptyDirs>true</includeEmptyDirs>-->
</configuration>
</plugin>
参考技术B excel是.xls、或 xlsx,还是逗号分隔的文本文件。。。。。。。。如果是后者就可能因为编码不对的。本回答被提问者和网友采纳

maven 项目中有 excel,, 打包后,打开excel为乱码

请教:
maven resources 目录下有 .xls 文件,查看了它的编码格式是utf-8,在eclipse中打开也正常,但执行maven命令后,console 是SUCCESS的,但war包里面的 .xls 打开后是乱码,,有遇到过的吗?怎么解决了??

参考技术A 这个问题有解决方法吗?
找到了,
在打包的时候,指定你的xls文件不被maven强制转码即可。
具体办法:

“<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
”的模块下
加入如下配置
<configuration>
<nonFilteredFileExtensions>
<nonFilteredFileExtension>xls</nonFilteredFileExtension>
</nonFilteredFileExtensions>
</configuration>
即可。本回答被提问者和网友采纳
参考技术B 我也是这个问题,正在寻找解决方案!

以上是关于maven打war包后,excel文件乱码,其余纯文本文件都正常的主要内容,如果未能解决你的问题,请参考以下文章

maven打包成war,方到tomcat里面运行,页面出现乱码

springboot打war包后部署到tomcat后访问返回404错误

maven打war包的时候如何设置不把web-inf下 lib文件夹的jar打包进去

关于Java打war包

maven如何打WAR包,看到target目录下面会生成JAR包,如何改成WAR?

Maven -- 将引用的本地jar文件打进war包里