在命令行中运行“mvn compile”因为中文报错

简介:

在命令行中运行mvn compile 报错:



 解决方法:

方式一:

使用maven-compiler-plugin插件,指定编码:

Xml代码   收藏代码
  1. <plugin>  
  2.                 <groupId>org.apache.maven.plugins</groupId>  
  3.                 <artifactId>maven-compiler-plugin</artifactId>  
  4.                 <configuration>  
  5.                     <source>1.6</source>  
  6.                     <target>1.6</target>  
  7.                 <encoding>UTF-8</encoding>  
  8.                 </configuration>  
  9.                   
  10.             </plugin>  

 

方式二:

 

<properties>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    </properties>

<plugin>

        <groupId>org.apache.maven.plugins</groupId>

        <artifactId>maven-compiler-plugin</artifactId>

        <configuration>

          <source>1.6</source>

          <target>1.6</target>

        </configuration>

      </plugin>

 

注意

(1)plugin标签在plugins标签中;

(2)properties标签在project标签下

相关文章
|
29天前
|
Java Maven
Maven命令行参数详解
Maven命令行参数详解
29 0
|
1月前
|
Java Maven
蓝易云 - Maven使用mvn命令时跳过test的参数
另外,还有一个参数 `-Dmaven.test.skip=true`也可以用来跳过测试,但是这个参数不仅跳过测试,还会跳过编译测试代码的阶段。所以,如果你的项目中有其他模块依赖测试代码,那么使用 `-Dmaven.test.skip=true`可能会导致构建失败。在大多数情况下,推荐使用 `-DskipTests`参数。
12 0
|
2月前
|
C语言 C++
VScode中C++多文件编译运行问题(使用code runner配置)
VScode中C++多文件编译运行问题(使用code runner配置)
|
8月前
|
Linux UED iOS开发
[√]pyinstaller打包的exe运行报错,找不到库
[√]pyinstaller打包的exe运行报错,找不到库
229 0
|
8月前
|
JavaScript
IDEA启动项目报错:非法字符: ‘\ufeff‘
IDEA启动项目报错:非法字符: ‘\ufeff‘
121 0
|
11月前
|
测试技术 Python
pytest--命令行常用参数
pytest--命令行常用参数
pytest--命令行常用参数
|
Windows
从 PyInstaller-pyi-grab_version 生成的可执行文件中提取版本信息
从 PyInstaller-pyi-grab_version 生成的可执行文件中提取版本信息
134 0
从 PyInstaller-pyi-grab_version 生成的可执行文件中提取版本信息
|
存储 Go
Go 命令行参数解析工具 pflag 使用
Go 命令行参数解析工具 pflag 使用
303 0
|
Python Windows
Python 把脚本编译打包成EXE文件 —— pyinstaller 的安装和使用
Python 把脚本编译打包成EXE文件 —— pyinstaller 的安装和使用
341 0
|
Java Shell Maven
mac安装maven后mvn命令可用,一段时间后又遇到zsh: command not found: mvn的问题
mac安装maven后mvn命令可用,一段时间后又遇到zsh: command not found: mvn的问题
775 0
mac安装maven后mvn命令可用,一段时间后又遇到zsh: command not found: mvn的问题