执行Maven install或Maven test命令时控制台输出乱码的解决办法

参考文章:执行Maven install或Maven test命令时控制台输出乱码的解决办法

【解决方案一】在Maven的pom.xml文件中增加如下代码:

<properties>  
    <argLine>-Dfile.encoding=UTF-8</argLine>  
</properties>

 【解决方案二】在Maven的pom.xml文件中增加如下代码:

<build>
    <plugins>  
        <plugin>  
            <groupId>org.apache.maven.plugins</groupId>  
            <artifactId>maven-surefire-plugin</artifactId>  
            <version>2.16</version>  
            <configuration>  
                <forkMode>once</forkMode>  
                <argLine>-Dfile.encoding=UTF-8</argLine>  
            </configuration>  
        </plugin>  
    </plugins>
</build>  

测试结果: 

[INFO] Scanning for projects...
[INFO] 
[INFO] -------------------------< com.swliu:mybatis >--------------------------
[INFO] Building mybatis 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ mybatis ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ mybatis ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ mybatis ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ mybatis ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.16:test (default-test) @ mybatis ---
[INFO] Downloading from aliyunmaven: https://maven.aliyun.com/repository/public/org/apache/maven/surefire/maven-surefire-common/2.16/maven-surefire-common-2.16.pom
[INFO] Downloaded from aliyunmaven: https://maven.aliyun.com/repository/public/org/apache/maven/surefire/maven-surefire-common/2.16/maven-surefire-common-2.16.pom (6.1 kB at 3.4 kB/s)
[INFO] Downloading from aliyunmaven: https://maven.aliyun.com/repository/public/org/apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2.pom
[INFO] Downloaded from aliyunmaven: https://maven.aliyun.com/repository/public/org/apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2.pom (1.6 kB at 1.7 kB/s)
[INFO] Downloading from aliyunmaven: https://maven.aliyun.com/repository/public/org/apache/maven/plugin-tools/maven-plugin-tools/3.2/maven-plugin-tools-3.2.pom
[INFO] Downloaded from aliyunmaven: https://maven.aliyun.com/repository/public/org/apache/maven/plugin-tools/maven-plugin-tools/3.2/maven-plugin-tools-3.2.pom (17 kB at 24 kB/s)
[INFO] Downloading from aliyunmaven: https://maven.aliyun.com/repository/public/org/apache/maven/surefire/surefire-api/2.16/surefire-api-2.16.pom
[INFO] Downloaded from aliyunmaven: https://maven.aliyun.com/repository/public/org/apache/maven/surefire/surefire-api/2.16/surefire-api-2.16.pom (2.3 kB at 3.2 kB/s)
[INFO] Downloading from aliyunmaven: https://maven.aliyun.com/repository/public/org/apache/maven/surefire/surefire-booter/2.16/surefire-booter-2.16.pom
[INFO] Downloaded from aliyunmaven: https://maven.aliyun.com/repository/public/org/apache/maven/surefire/surefire-booter/2.16/surefire-booter-2.16.pom (2.8 kB at 4.7 kB/s)
[INFO] Downloading from aliyunmaven: https://maven.aliyun.com/repository/public/org/apache/maven/surefire/maven-surefire-common/2.16/maven-surefire-common-2.16.jar
[INFO] Downloading from aliyunmaven: https://maven.aliyun.com/repository/public/org/apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2.jar
[INFO] Downloading from aliyunmaven: https://maven.aliyun.com/repository/public/org/apache/maven/surefire/surefire-booter/2.16/surefire-booter-2.16.jar
[INFO] Downloading from aliyunmaven: https://maven.aliyun.com/repository/public/org/apache/maven/surefire/surefire-api/2.16/surefire-api-2.16.jar
[INFO] Downloaded from aliyunmaven: https://maven.aliyun.com/repository/public/org/apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2.jar (15 kB at 19 kB/s)
[INFO] Downloaded from aliyunmaven: https://maven.aliyun.com/repository/public/org/apache/maven/surefire/maven-surefire-common/2.16/maven-surefire-common-2.16.jar (264 kB at 267 kB/s)
[INFO] Downloaded from aliyunmaven: https://maven.aliyun.com/repository/public/org/apache/maven/surefire/surefire-booter/2.16/surefire-booter-2.16.jar (40 kB at 33 kB/s)
[INFO] Downloaded from aliyunmaven: https://maven.aliyun.com/repository/public/org/apache/maven/surefire/surefire-api/2.16/surefire-api-2.16.jar (149 kB at 51 kB/s)
[INFO] Surefire report directory: D:\software\workspace\sts\mybatis\target\surefire-reports
[INFO] Downloading from aliyunmaven: https://maven.aliyun.com/repository/public/org/apache/maven/surefire/surefire-junit4/2.16/surefire-junit4-2.16.pom
[INFO] Downloaded from aliyunmaven: https://maven.aliyun.com/repository/public/org/apache/maven/surefire/surefire-junit4/2.16/surefire-junit4-2.16.pom (2.5 kB at 2.6 kB/s)
[INFO] Downloading from aliyunmaven: https://maven.aliyun.com/repository/public/org/apache/maven/surefire/surefire-providers/2.16/surefire-providers-2.16.pom
[INFO] Downloaded from aliyunmaven: https://maven.aliyun.com/repository/public/org/apache/maven/surefire/surefire-providers/2.16/surefire-providers-2.16.pom (2.4 kB at 2.5 kB/s)
[INFO] Downloading from aliyunmaven: https://maven.aliyun.com/repository/public/org/apache/maven/surefire/surefire-junit4/2.16/surefire-junit4-2.16.jar
[INFO] Downloaded from aliyunmaven: https://maven.aliyun.com/repository/public/org/apache/maven/surefire/surefire-junit4/2.16/surefire-junit4-2.16.jar (64 kB at 45 kB/s)

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running mybatis.TestMybatis
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.ibatis.reflection.Reflector (file:/D:/software/workspace/user/swliu/.m2/repository/org/mybatis/mybatis/3.2.8/mybatis-3.2.8.jar) to method java.lang.Class.checkPackageAccess(java.lang.SecurityManager,java.lang.ClassLoader,boolean)
WARNING: Please consider reporting this to the maintainers of org.apache.ibatis.reflection.Reflector
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Tue Jul 05 15:57:22 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
2022-07-05 15:57:22,770 [main] DEBUG [com.swliu.mybatis.pojo.UserMapper.delete] - ==>  Preparing: delete from user where id=? 
2022-07-05 15:57:22,842 [main] DEBUG [com.swliu.mybatis.pojo.UserMapper.delete] - ==> Parameters: 12(Integer)
2022-07-05 15:57:22,842 [main] DEBUG [com.swliu.mybatis.pojo.UserMapper.delete] - <==    Updates: 0
Tue Jul 05 15:57:22 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
2022-07-05 15:57:22,882 [main] DEBUG [com.swliu.mybatis.pojo.UserMapper.insert] - ==>  Preparing: insert into user(name,birthday,address) values(?,?,?) 
2022-07-05 15:57:22,902 [main] DEBUG [com.swliu.mybatis.pojo.UserMapper.insert] - ==> Parameters: 刘德华(String), 2022-07-05 15:57:22.882(Timestamp), 中国香港(String)
2022-07-05 15:57:22,912 [main] DEBUG [com.swliu.mybatis.pojo.UserMapper.insert] - <==    Updates: 1
Tue Jul 05 15:57:23 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
2022-07-05 15:57:23,052 [main] DEBUG [com.swliu.mybatis.pojo.UserMapper.findAll] - ==>  Preparing: select id,name,birthday,address from user 
2022-07-05 15:57:23,052 [main] DEBUG [com.swliu.mybatis.pojo.UserMapper.findAll] - ==> Parameters: 
2022-07-05 15:57:23,102 [main] DEBUG [com.swliu.mybatis.pojo.UserMapper.findAll] - <==      Total: 5
User [id=1, name=夏言, birthday=Thu Jan 01 00:00:00 CST 1573, address=桂州村]
User [id=2, name=严嵩, birthday=Thu Jan 01 00:00:00 CST 1587, address=分宜县城介桥村]
User [id=13, name=Jack, birthday=Tue Jul 05 15:03:48 CST 2022, address=中国香港]
User [id=14, name=Jack, birthday=Tue Jul 05 15:49:39 CST 2022, address=中国香港]
User [id=15, name=刘德华, birthday=Tue Jul 05 15:57:23 CST 2022, address=中国香港]
Tue Jul 05 15:57:23 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
2022-07-05 15:57:23,172 [main] DEBUG [com.swliu.mybatis.pojo.UserMapper.findOne] - ==>  Preparing: select id,name,birthday,address from user where id=? 
2022-07-05 15:57:23,172 [main] DEBUG [com.swliu.mybatis.pojo.UserMapper.findOne] - ==> Parameters: 2(Integer)
2022-07-05 15:57:23,172 [main] DEBUG [com.swliu.mybatis.pojo.UserMapper.findOne] - <==      Total: 1
User [id=2, name=严嵩, birthday=Thu Jan 01 00:00:00 CST 1587, address=分宜县城介桥村]
Tue Jul 05 15:57:23 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
2022-07-05 15:57:23,222 [main] DEBUG [com.swliu.mybatis.pojo.UserMapper.update] - ==>  Preparing: update user set name=? where name='刘德华' 
2022-07-05 15:57:23,222 [main] DEBUG [com.swliu.mybatis.pojo.UserMapper.update] - ==> Parameters: Jack(String)
2022-07-05 15:57:23,232 [main] DEBUG [com.swliu.mybatis.pojo.UserMapper.update] - <==    Updates: 1
Tue Jul 05 15:57:23 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
2022-07-05 15:57:23,352 [main] DEBUG [com.swliu.mybatis.pojo.UserMapper.findYear] - ==>  Preparing: select id,name,birthday,address from user where year(birthday) > 1580 and year(birthday) < 1590 
2022-07-05 15:57:23,352 [main] DEBUG [com.swliu.mybatis.pojo.UserMapper.findYear] - ==> Parameters: 
2022-07-05 15:57:23,352 [main] DEBUG [com.swliu.mybatis.pojo.UserMapper.findYear] - <==      Total: 1
User [id=2, name=严嵩, birthday=Thu Jan 01 00:00:00 CST 1587, address=分宜县城介桥村]
Tue Jul 05 15:57:23 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
2022-07-05 15:57:23,452 [main] DEBUG [com.swliu.mybatis.pojo.UserMapper.order] - ==>  Preparing: select id,name,birthday,address from user order by name 
2022-07-05 15:57:23,452 [main] DEBUG [com.swliu.mybatis.pojo.UserMapper.order] - ==> Parameters: 
2022-07-05 15:57:23,452 [main] DEBUG [com.swliu.mybatis.pojo.UserMapper.order] - <==      Total: 5
User [id=13, name=Jack, birthday=Tue Jul 05 15:03:48 CST 2022, address=中国香港]
User [id=14, name=Jack, birthday=Tue Jul 05 15:49:39 CST 2022, address=中国香港]
User [id=15, name=Jack, birthday=Tue Jul 05 15:57:23 CST 2022, address=中国香港]
User [id=2, name=严嵩, birthday=Thu Jan 01 00:00:00 CST 1587, address=分宜县城介桥村]
User [id=1, name=夏言, birthday=Thu Jan 01 00:00:00 CST 1573, address=桂州村]
Tue Jul 05 15:57:23 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
2022-07-05 15:57:23,542 [main] DEBUG [com.swliu.mybatis.pojo.UserMapper.findCount] - ==>  Preparing: select count(*) from user 
2022-07-05 15:57:23,542 [main] DEBUG [com.swliu.mybatis.pojo.UserMapper.findCount] - ==> Parameters: 
2022-07-05 15:57:23,542 [main] DEBUG [com.swliu.mybatis.pojo.UserMapper.findCount] - <==      Total: 1
5
Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.81 sec - in mybatis.TestMybatis

Results :

Tests run: 8, Failures: 0, Errors: 0, Skipped: 0

[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ mybatis ---
[INFO] Building jar: D:\software\workspace\sts\mybatis\target\mybatis-0.0.1-SNAPSHOT.jar
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ mybatis ---
[INFO] Installing D:\software\workspace\sts\mybatis\target\mybatis-0.0.1-SNAPSHOT.jar to D:\software\workspace\user\swliu\.m2\repository\com\swliu\mybatis\0.0.1-SNAPSHOT\mybatis-0.0.1-SNAPSHOT.jar
[INFO] Installing D:\software\workspace\sts\mybatis\pom.xml to D:\software\workspace\user\swliu\.m2\repository\com\swliu\mybatis\0.0.1-SNAPSHOT\mybatis-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  17.052 s
[INFO] Finished at: 2022-07-05T15:57:24+08:00
[INFO] ------------------------------------------------------------------------

 

  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值