Jenkins部署Maven项目时提示找不到JDK问题的解决方案
2015-11-07 20:17
731 查看
背景描述
今天我将一个Maven Web项目在Jenkins中配置自动构建部署时,遇到报错:[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project personal: Compilation failure [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
一开始不明白指的什么意思,在stackoverflow上查了一下,找到了这样一个链接,虽然提问者问的是Eclipse中Maven运行的问题,但是最后面提问者的解决方案给我了一个启发。
http://stackoverflow.com/questions/19655184/no-compiler-is-provided-in-this-environment-perhaps-you-are-running-on-a-jre-ra
具体细节和解决方案
这肯定是Maven在构建时查找JDK遇到了障碍,可能是某处环境变量配置没有到位。我pom.xml中关于maven-compiler-plugin编译插件的内容是这样的:<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <target>1.7</target> <compilerArguments> <endorseddirs>${endorsed.dir}</endorseddirs> </compilerArguments> </configuration> </plugin>
stackoverflow上的答案给我的启发就是我这里<configuration>中的JDK配置不明确,需要指定具体的地址:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <fork>true</fork> <executable>C:\Program Files\Java\jdk1.8.0_66\bin\javac.exe</executable> </configuration> </plugin>
在将pom.xml修改之后,Jenkins确实构建成功了。
这个问题和我之前写的博客使用Ant工程创建Jenkins Job时可能遇到的几个问题中的"2. Java EE server问题"有相似之处,那边需要明确的指明Server所在目录,这里也需要明确的指明JDK所在目录。
Jenkins部署Maven项目时提示找不到JDK问题的解决方案
相关文章推荐
- sessionFactory为空之spring依赖注入
- classpath、path、JAVA_HOME的作用(转)
- JVM JRE JDK区别与联系
- Java语句
- Java数据类型
- 达内学习日志Day50:使用SpringMVC完成登录操作
- Java零散知识点总结
- myeclipse 用tocmat部署项目没反应
- 笔记:学习JavaWeb开发第三课
- Java方法的参数传递
- java二叉树的实现
- java_Collection 类集
- Java字符串常用方法
- JAVA内存存储分配粗略讲解
- 【JDK源码】ArrayList线程不安全详解—Fail-Fast机制总结
- Javabean
- java设计模式
- java多线程细节归纳汇总
- Java中的final理解
- spring 方法拦截器 MethodInterceptor接口