maven - 如何在 exec-maven-plugin 中设置 file.encoding 属性?

标签 maven utf exec-maven-plugin

我试图通过 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/

相关文章:

java - 在 OS X 上运行 Maven 时 ${java.home} 发生变化

java - 为什么现有的 Maven 存储库丢失了?

unicode - Unicode 可以映射多少个字符?

eclipse - gwt-maven-plugin 与 Eclipse Indigo

java - Fileoutputstream 和 UTF-8 文件下载

Android从文本文件中获取UTFDataFormatException读取UTF

maven - 使用带有参数的 Maven 'exec:exec'

java - 传递环境变量以在 Maven 中执行进程

maven - 使用exec-maven-plugin时如何防止测试运行

java - 在maven2中编译有注释的项目时出错