标签:工程 trace 目录 生成 fine sample 测试覆盖率 build resources
我们使用maven做一些日常的工作开发的时候,无非是想利用这个工具带来的一些便利。比如它带来的依赖管理,方便我们打包和部署运行。这里几个常见的插件就是和这些工程中常用的步骤相关。
这个插件就如同名字所显示的这样,用来编译源代码的。最开始碰到这个插件是在于有的时候我们下载了一些工程需要编译的时候,比如我们输入命令:mvn install ,但是系统编译的时候报错了,错误的信息如下:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project springJMS: Compilation failure: Compilation failure: [ERROR] /home/frank/programcode/SpringJMSSample/src/main/java/huangbowen/net/jms/MessageSender.java:[6,1] error: annotations are not supported in -source 1.3 [ERROR] [ERROR] (use -source 5 or higher to enable annotations) [ERROR] /home/frank/programcode/SpringJMSSample/src/main/java/net/EmbedBrokerApp.java:[5,7] error: static import declarations are not supported in -source 1.3 [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
从错误显示的信息我们就可以看出,这是因为编译的时候是默认用的javac 1.3版本的,太老了不支持代码里的特性。为了修改这个问题,我们需要设置编译器的版本。解决这个问题的办法也比较简单,就是直接在后面的插件部分增加如下的插件,比如如下部分,将编译器的版本设定为1.6:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<!-- 编译插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<!-- 源码风格使用1.7风格 -->
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<!--必须添加compilerArgument配置,才能使用JFinal的Controller方法带参数的功能-->
<compilerArgument>-parameters</compilerArgument>
<!--<compilerArgs>-->
<!--<compilerArg>-parameters</compilerArg>-->
<!--</compilerArgs>-->
<!-- 编译跳过代码编译类 -->
<excludes>
<!-- 排除应用程序编译类 -->
<exclude>**/ApplicationCodeGenerator.java</exclude>
</excludes>
</configuration>
</plugin>
<plugins>
<!-- Maven 编译错误 Dynamic Web Module 3.0 requires Java 1.6 or newer 解决方案 -->
<!-- define the project compile level ,指定编译级别1.7-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
以下几种插件都是maven项目中常用插件,具体用到时候可以网上自行查找使用方法,在此不一一详解:
标签:工程 trace 目录 生成 fine sample 测试覆盖率 build resources
原文地址:https://www.cnblogs.com/gllegolas/p/11611455.html