Compiling Sources Using A Different JDK :
[INFO] Reactor Summary:
[INFO]
[INFO] bi-platform ........................................ SUCCESS [ 3.000 s]
[INFO] fileserver ......................................... FAILURE [ 1.597 s]
[INFO] model .............................................. SKIPPED
[INFO] cache .............................................. SKIPPED
[INFO] common-api ......................................... SKIPPED
[INFO] schedule ........................................... SKIPPED
[INFO] designer ........................................... SKIPPED
[INFO] parser ............................................. SKIPPED
[INFO] tesseract .......................................... SKIPPED
[INFO] queryrouter ........................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.768 s
[INFO] Finished at: 2015-10-20T15:45:37+08:00
[INFO] Final Memory: 21M/181M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project fileserver: Fatal error compiling: 无效的目标发行版: 1.8 -> [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/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :fileserver
maven可以指定使用另外的JDK来编译。
http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-using-different-jdk.html
<project> [...] <build> [...] <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.5.1</version> <configuration> <verbose>true</verbose> <fork>true</fork> <executable><!-- path-to-javac --></executable> <compilerVersion>1.3</compilerVersion> </configuration> </plugin> </plugins> [...] </build> [...] </project>To avoid hard-coding a filesystem path for the executable, you can use a property. For example:
<executable>${JAVA_1_4_HOME}/bin/javac</executable>Each developer then defines this property in settings.xml, or sets an environment variable, so that the build remains portable.
<settings> [...] <profiles> [...] <profile> <id>compiler</id> <properties> <JAVA_1_4_HOME>C:\Program Files\Java\j2sdk1.4.2_09</JAVA_1_4_HOME> </properties> </profile> </profiles> [...] <activeProfiles> <activeProfile>compiler</activeProfile> </activeProfiles> </settings>If you build with a different JDK, you may want to customize the jar file manifest. 但是在windows下并没有用,因为执行mvn install的时候,实际执行的命令是拼接出来的,所以,按照上面例子的配置,假设你的cmd窗口所在路径是C:\,那么本来执行的命令是javac -d ......就会变成了
C:\C:\Program Files\Java\j2sdk1.4.2_09\bin\javac -d ......执行的时候会出错。 如果不嫌麻烦,可以手动执行命令, mvn install -X > err.txt 在输出中找到出错的位置,找到原始的命令,复制出来,稍作修改,在cmd窗口中直接执行。 或者更简单的,直接将将JAVA_HOME改为jdk8的目录
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。