我的 pom 文件中有 maven-compiler-plugin 如下,但编译器对泛型参数很生气。我的 Maven 版本是“Apache Maven 3.0.3 (r1075438; 2011-02-28 19:31:09+0200)”
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerVersion>1.6</compilerVersion>
</configuration>
</plugin>
编译器生气的类如下
List<EulTransactionHistory> list = hibernateTemplate.findByCriteria(criteria, -1, 1);
EulTransactionHistory existingRecord = DBUtils.oneAndOnlyOne(list);
DBUtils.oneAndOnlyOne 的规范如下
public static <T> T oneAndOnlyOne(List<T> list) {...}
最后的例外是
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project etlscheduler: Compilation failure: Compilation failure SchedulerDaoImpl.java:[329,18] incompatible types
found : java.lang.Object
required: com.aric.etlscheduler.domain.EulTransactionHistory
此外,当我用 eclipse 编译这个项目时,它会成功编译。