Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Maven无法处理Unicode字符_Java_Maven_Unicode - Fatal编程技术网

Java Maven无法处理Unicode字符

Java Maven无法处理Unicode字符,java,maven,unicode,Java,Maven,Unicode,我用java运行代码,Unicode字符可以正确显示,但当我用maven(Mvn clean test)运行代码时,Unicode字符显示不正确。我有用户范围报告和扩展报告显示日志与不正确的Unicode字符,太 <groupId>groupId</groupId> <artifactId>api</artifactId> <version>1.0-SNAPSHOT</version> <build> &

我用java运行代码,Unicode字符可以正确显示,但当我用maven(Mvn clean test)运行代码时,Unicode字符显示不正确。我有用户范围报告和扩展报告显示日志与不正确的Unicode字符,太

<groupId>groupId</groupId>
<artifactId>api</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                 <encoding>UTF-8</encoding>
                <fork>true</fork>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.20</version>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>.\testsuites\run1.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.9.9</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.11</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.11</version>
    </dependency>
    <dependency>
        <groupId>com.aventstack</groupId>
        <artifactId>extentreports</artifactId>
        <version>4.0.9</version>
    </dependency>
    <dependency>
        <groupId>com.relevantcodes</groupId>
        <artifactId>extentreports</artifactId>
        <version>2.41.2</version>
    </dependency>
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20180130</version>
    </dependency>
    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>javax.mail-api</artifactId>
        <version>1.6.0</version>
    </dependency>
    <dependency>
        <groupId>com.samczsun</groupId>
        <artifactId>skype4j</artifactId>
        <version>0.1.5</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpcore</artifactId>
        <version>4.4.6</version>
    </dependency>

    <dependency>
        <groupId>com.googlecode.json-simple</groupId>
        <artifactId>json-simple</artifactId>
        <version>1.1.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.pdfbox</groupId>
        <artifactId>pdfbox</artifactId>
        <version>2.0.11</version>
    </dependency>
    <dependency>
        <groupId>ru.yandex.qatools.ashot</groupId>
        <artifactId>ashot</artifactId>
        <version>1.5.4</version>
    </dependency>
    <dependency>
        <groupId>net.gpedro.integrations.slack</groupId>
        <artifactId>slack-webhook</artifactId>
        <version>1.4.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>ooxml-schemas</artifactId>
        <version>1.3</version>
    </dependency>

    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4.7</version>
    </dependency>
    <dependency>
        <groupId>com.google.apis</groupId>
        <artifactId>google-api-services-sheets</artifactId>
        <version>v4-rev525-1.23.0</version>
    </dependency>

    <dependency>
        <groupId>com.google.apis</groupId>
        <artifactId>google-api-services-drive</artifactId>
        <version>v3-rev124-1.23.0</version>
    </dependency>
    <dependency>
        <groupId>com.google.api-client</groupId>
        <artifactId>google-api-client</artifactId>
        <version>1.23.0</version>
    </dependency>

    <dependency>
        <groupId>com.google.oauth-client</groupId>
        <artifactId>google-oauth-client-jetty</artifactId>
        <version>1.23.0</version>
    </dependency>
    <dependency>
        <groupId>com.jayway.jsonpath</groupId>
        <artifactId>json-path</artifactId>
        <version>2.4.0</version>
    </dependency>
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.6</version>
    </dependency>
    <dependency>
        <groupId>io.rest-assured</groupId>
        <artifactId>rest-assured</artifactId>
        <version>3.3.0</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.53.1</version>
    </dependency>

    <dependency>
        <groupId>net.javacrumbs.json-unit</groupId>
        <artifactId>json-unit</artifactId>
        <version>1.5.0</version>
        <scope>compile</scope>
    </dependency>

</dependencies>
实际结果: ?y l v?n b?n ti?ng vi?t

预期结果:
是的,是的ản tiếng việt

我通过在POM.xml的sureFire插件上添加DFile编码UTF-8解决了我的问题

      <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.20</version>
            <configuration>
                <argLine>-Dfile.encoding=UTF-8</argLine>
                <suiteXmlFiles>
                    <suiteXmlFile>.\testsuites\run1.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>

org.apache.maven.plugins
maven surefire插件
2.20
-文件编码=UTF-8
.\testsuites\run1.xml

我通过在POM.xml的sureFire插件上添加文件编码UTF-8解决了我的问题

      <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.20</version>
            <configuration>
                <argLine>-Dfile.encoding=UTF-8</argLine>
                <suiteXmlFiles>
                    <suiteXmlFile>.\testsuites\run1.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>

org.apache.maven.plugins
maven surefire插件
2.20
-文件编码=UTF-8
.\testsuites\run1.xml

,有很多可能的原因,maven不是最可能的原因:您的Java源代码真的是用UTF-8编码的吗?您在哪个操作系统上运行代码?显示控制台使用什么代码页/编码/字体?我通过在插件maven surefire上将argLine:-Dfile.encoding=UTF-8添加到POM.xml来解决问题-plugin@Raw2008你可以写下来作为回答和接受it@barbsan谢谢你的导游有很多可能的原因,maven不是最可能的:您的Java源代码真的是用UTF-8编码的吗?您在哪个操作系统上运行代码?显示控制台使用什么代码页/编码/字体?我通过在插件maven surefire上将argLine:-Dfile.encoding=UTF-8添加到POM.xml来解决问题-plugin@Raw2008你可以写下来作为回答和接受it@barbsan谢谢你的导游