简体   繁体   English

在Jenkins中编译Java代码会收到错误:不兼容的类型

[英]Compiling java code in Jenkins get error: incompatible types

I configed Jenkins to compile and build java project. 我配置Jenkins来编译和构建Java项目。 But I got the below error 但是我收到以下错误

[javac] C:\Users\Administrator\.jenkins\workspace\AMRM\AMRM-rad-workspace\AMRM\src\com\bidv\amrm\struts2\jdbc\DeclareAppImpl.java:232: error: incompatible types
    [javac]                   return DB.getConnection().queryForObject(sql, new Object[]{id}, new DTOMapper());
    [javac]                                                           ^
    [javac]   required: ListAppDTO
    [javac]   found:    Object

I found a solution to fix is adding the line: @SuppressWarnings("unchecked") before relate function in java code 我发现要解决的解决方案是添加以下行:@SuppressWarnings(“ unchecked”)在Java代码中的related函数之前

But, are there any other solution ? 但是,还有其他解决方案吗? Such as config in Jenkins ? 如詹金斯的配置? I don't want to change my code, because My project still compiled success in Eclipse (but error in Jenkins) 我不想更改代码,因为我的项目仍在Eclipse中成功编译(但在Jenkins中出错)

I found the reason, it is because my jenkins still use a different java version. 我找到了原因,这是因为我的詹金斯仍然使用其他Java版本。

So I pass the correct version (1.6) into build statement javac, then it is successful (java.home = C:\\Program Files\\Java\\jdk1.6.0_23) 因此,我将正确的版本(1.6)传递到了build语句javac中,然后它成功了(java.home = C:\\ Program Files \\ Java \\ jdk1.6.0_23)

<javac fork="yes" executable="${java.home}\bin\javac" includeantruntime="false" encoding="utf-8" srcdir="${workspace}/${project.name}/src" destdir="${workspace}/${project.name}/WebContent/WEB-INF/classes" classpath="${was_cp}">
        </javac>

But, I got another error: 但是,我又遇到了一个错误:

Caused by: java.io.IOException: Cannot run program "C:\java1.6\bin\javac": CreateProcess error=206, The filename or extension is too long.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM