jdk版本问题导致的error: reference to query is ambiguous

1 用的是开源项目Davinci,在其之上进行改造
情况是这样的,在test的jenkins环境中是可以正常构建的当前项目的,但是准备上预发布的时候发现jenkins报错如下:
 
jdk版本问题导致的error: reference to query is ambiguous_第1张图片
 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project davinci-server_3.01: Compilation failure: Compilation failure:
[ERROR] /home/data_jenkins/workspace/bi-davinci/server/src/main/java/edp/core/utils/SqlUtils.java:[251,14] error: reference to query is ambiguous
[ERROR] both method query(String,ResultSetExtractor) in JdbcTemplate and method query(String,RowCallbackHandler) in JdbcTemplate match
[ERROR] where T is a type-variable:
[ERROR] T extends Object declared in method query(String,ResultSetExtractor)
[ERROR] /home/data_jenkins/workspace/bi-davinci/server/src/main/java/edp/davinci/service/excel/SheetWorker.java:[76,20] error: reference to query is ambiguous
[ERROR] both method query(String,ResultSetExtractor) in JdbcTemplate and method query(String,RowCallbackHandler) in JdbcTemplate match
[ERROR] where T is a type-variable:
[ERROR] T extends Object declared in method query(String,ResultSetExtractor)
[ERROR] /home/data_jenkins/workspace/bi-davinci/server/src/main/java/edp/davinci/service/excel/SheetWorker.java:[76,26] error: incompatible types: cannot infer type-variable(s) T
[ERROR] (actual and formal argument lists differ in length)
[ERROR] where T is a type-variable:
[ERROR] T extends Object declared in method getObject(int,Class)
[ERROR] /home/data_jenkins/workspace/bi-davinci/server/src/main/java/edp/davinci/service/excel/SheetWorker.java:[145,16] error: reference to query is ambiguous
[ERROR] both method query(String,ResultSetExtractor) in JdbcTemplate and method query(String,RowCallbackHandler) in JdbcTemplate match
[ERROR] where T is a type-variable:
[ERROR] T extends Object declared in method query(String,ResultSetExtractor)
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project davinci-server_3.01: Compilation failure
 
2 问题排查过程
1 首先上去jenkins服务器上用如下命令看版本:
# mvn -version  // 可以看到版本为:jdk 1.8.0_11、maven 3.6.1
看样子似乎没啥毛病,jdk也是1.8。先排除这个问题
 
 
 
2 然后我去项目的pom.xml查看如下,原本以为可能是maven-compiler-plugin版本问题:
 
jdk版本问题导致的error: reference to query is ambiguous_第2张图片
 
并将version的3.6.1分别改3.2、3.5.3、3.8.0之后,构建依旧报原来的错误,所以可以排除这个可能性
 
然后猜测是maven本地仓库下载损坏的问题,所以用mvn -version找到对应maven目录然后找到仓库位置为如下:
# cd ~
# cd .m2/repository
# rm -rf ./*     // 清空所有
然后重新构建jenkins,然后依旧报原来的错误,所以可以排除这个可能性。
 
然后猜测是jdk版本问题吗?但是都是jdk1.8看样子真没毛病。但是还是去检查jdk版本的问题了,首先去test环境的jenkins找到对应的jdk版本为jdk .8.0_211,貌似有点不一样,然后就把测试环境的jdk拷到预发布的jenkins中,并修改JAVA_HOME为jdk .8.0_211路径,最后重新构建发现依旧报原来的错误,本来是排除了这个可能性的。但是跟同事商量后,在mvn的命令中加上-X 把debug信息打印出来,其关键问题信息如下:
 
 
上面发现jdk版本居然还是1.8.0_11????坑爹啊,然后就去找jenkins怎么设置jdk版本(设置连接为: https://jingyan.baidu.com/article/aa6a2c140a6c564c4d19c468.html)。配了jdk 1.8.0_211之后构建居然可以了!!
 
总结:就是jdk版本bug的锅。。。。。下面附上一张图:
 
jdk版本问题导致的error: reference to query is ambiguous_第3张图片
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

你可能感兴趣的:(JAVA)