Maven Jar 编码问题
如何指定(或“强制”)maven jar 插件使用我的特定编码(UTF-8)?
我的构建插件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<phase>package</phase>
<id>configurations-test</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classesDirectory>target/test</classesDirectory>
<forceCreation>true</forceCreation>
<finalName>${artifactId}-test</finalName>
</excludes>
</configuration>
</execution>
</executions></plugin>
我在父 pom 中设置编码,并且每个副本都使用正确的编码执行,
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
我在创建 Jar 之前控制了文件,这些文件格式良好。
注意,我做了很多尝试,在配置中添加特定编码,但它仍然不起作用,在我打包的 Jars 中,我发现格式不正确的字符(如 é,应该是 é)
解压缩的文件(html、xml、属性等) ) 包含诸如 é 之类的字符,而不是 é。
How do I specify (or "force") the maven jar plugin to use my specific encoding (UTF-8) ?
My build plugin :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<phase>package</phase>
<id>configurations-test</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classesDirectory>target/test</classesDirectory>
<forceCreation>true</forceCreation>
<finalName>${artifactId}-test</finalName>
</excludes>
</configuration>
</execution>
</executions></plugin>
I set the encoding in the parent pom and every copies is executed with the right encoding
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
I controled the files just before the Jar is created, these are well formated.
Note, I did many tried addind specific encoding to the configuration but it still won't work, in my packaged Jars I found unwell formatted characters (like é, which should be é)
The unzipped files (html, xml, properties etc.) contains such characters like é instead of é.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
jar 不会弄乱你的文件。它只是复制字节。另一方面,资源插件可能会。
您需要设置
${project.build.sourceEncoding}
。请参阅 http://maven.apache.org/plugins/ maven-resources-plugin/copy-resources-mojo.html。
jar doesn't mess with your files. It just copies the bytes. On the other hand, the resource plugin might.
You need to set
${project.build.sourceEncoding}
.See http://maven.apache.org/plugins/maven-resources-plugin/copy-resources-mojo.html.
指定 UTF 编码属性:
请注意,当我使用 UTF 编码部署到 wls 10.3.6 时,我遇到了以下错误,不确定其他错误。
不知道如何配置 wls 来读取 utf zip,
所以现在我使用 ASCII 作为编码,并且 wls 不会抱怨
specify UTF encoding property:
be warned, i've experienced the following error when I use UTF encoding deploying to wls 10.3.6, not sure others.
not sure how to configure wls to read utf zips
so now i'm using ASCII as the encoding, and wls doesn't complain