maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
...
</build>
...
</project>
4.2 如何指定自己的目录结构?
可以通过设置 <build>
节点下 <sourceDirectory>
, <resources>
参数指定。
4.3 在 pom 文件中配置了依赖,编译时还会报错。
下载的 jar 文件可能有问题。
- 检查 maven 仓库地址,在搜索条件中检查 groupId 和 artifactId 是否正确。
mvn clean
清理文件。
mvn package
重新编译。
4.4 [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
POM 文件中没有指定编译时编码格式,可加入下面属性指定为 UTF-8。
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
类似的问题: [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
4.5 Invalid project description. … overlaps the workspace …
Eclipse 新建 Maven 项目时,可能会报告此错误。解决办法两种:
- 选择 workspace 以外的目录作为项目目录;
- 新建 Java Project,然后转为 Maven 项目:右键菜单
Config
-> Convert to Maven Project
4.6 Warning:java: 源值1.5已过时, 将在未来所有发行版中删除
Idea 在 Maven Build 时发出警告,在 pom.xml
中加入以下内容:
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
我喜欢程序员,他们单纯、固执、容易体会到成就感;面对压力,能够挑灯夜战不眠不休;面对困难,能够迎难而上挑战自我。他们也会感到困惑与傍徨,但每个程序员的心中都有一个比尔盖茨或是乔布斯的梦想“用智慧开创属于自己的事业”。我想说的是,其实我是一个程序员。(新浪微博:@唐尤华)
查看唐尤华的更多文章 >>