我试图通过 exec-maven-plugin 执行我的独立应用程序,但它以 WIN 编码而不是 UTF-8 开头。我阅读了有关 Java 命令行键 -Dfile.encoding=UTF-8 的信息。如何将此属性设置为我的应用程序? 谢谢。
maven pom:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<executable>java</executable>
<mainClass>my.main.Class</mainClass>
</configuration>
</plugin>
最佳答案
要为 mvn exec:java
设置编码,设置 MAVEN_OPTS
环境变量,例如:
export MAVEN_OPTS=-Dfile.encoding=utf-8
这里是 exec-maven-plugin usage页面说:
Note: The java goal doesn't spawn a new process. Any VM specific option that you want to pass to the executed class must be passed to the Maven VM using the MAVEN_OPTS environment variable. E.g.
MAVEN_OPTS=-Xmx1024m
Otherwise consider using the exec goal.
关于maven - 如何在 exec-maven-plugin 中设置 file.encoding 属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9005306/