在現有的項目中,我建立與搖籃(Windows 7中的Java 1.7.0.15)我已經升級MyBatis的庫如下:MyBatis的升級原因,建立自己的錯誤
// MyBatis
compile "org.mybatis:mybatis:3.2.1"
compile "org.mybatis:mybatis-spring:1.2.0"
//compile "org.mybatis:mybatis:3.0.6"
//compile "org.mybatis:mybatis-spring:1.0.2"
現在,當我建我得到以下錯誤:
11:38:37.308 [INFO] [org.gradle.api.internal.tasks.compile.jdk6.Jdk6JavaCompiler]
Compiling with JDK 6 Java compiler API.
11:38:39.147 [ERROR] [system.err] ...java:14: error: DateTimeHandler is not abstract and does not override abstract method getNullableResult(ResultSet,int) in BaseTypeHandler
11:38:39.153 [ERROR] [system.err] public class DateTimeHandler extends BaseTypeHandler<DateTime> {
11:38:39.274 [ERROR] [system.err] Note: Some input files use or override a deprecated API.
11:38:39.279 [ERROR] [system.err] Note: Recompile with -Xlint:deprecation for details.
11:38:39.284 [ERROR] [system.err] 1 error
我已經檢查了類百倍,它並在此改變正確的方法(實際上Eclipse的同意,因爲它表明沒有錯誤)。
我不知道爲什麼當一切都應該在Java 7下時,使用內部的Gradle類jdk6。有人知道這裏發生了什麼事嗎?
這搖籃不喜歡的類:
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedTypes;
import org.joda.time.DateTime;
@MappedTypes(value = DateTime.class)
public class DateTimeHandler extends BaseTypeHandler<DateTime> {
public DateTimeHandler() {
}
@Override
public void setNonNullParameter(PreparedStatement ps, int i, DateTime parameter, JdbcType jdbcType) throws SQLException {
ps.setTimestamp(i, new java.sql.Timestamp((parameter.toDate()).getTime()));
}
@Override
public DateTime getNullableResult(ResultSet rs, String columnName) throws SQLException {
java.sql.Timestamp sqlTimestamp = rs.getTimestamp(columnName);
if (sqlTimestamp != null) {
return new DateTime(sqlTimestamp.getTime());
}
return null;
}
@Override
public DateTime getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
java.sql.Timestamp sqlTimestamp = cs.getTimestamp(columnIndex);
if (sqlTimestamp != null) {
return new DateTime(sqlTimestamp.getTime());
}
return null;
}
}
但有不妥的地方,據我所看到的。正確的方法已經過時。
行固定構建:
添加在該方法中:
公共的DateTime getNullableResult(結果集RS,INT columnIndex)拋出的SQLException;
如果我在此方法上使用覆蓋註釋,但沒有Gradle構建成功完成的註釋,Eclipse錯誤。如果該方法被刪除,Gradle會產生一個錯誤,說該類需要重寫帶有該簽名的方法(或者被聲明爲抽象的)。
所以,雖然我的問題已解決,但我並不真正瞭解此錯誤的性質。
謝謝,使用搖籃1.4,-v的gradle顯示 JVM:1.7.0_15公司(Oracle Corporation 23.7-B01) 操作系統:Windows 7 6.1 AMD64 – 2013-03-27 12:33:06
堆棧跟蹤是:致:org.gradle.api.internal。 tasks.compile.CompilationFailedException:編譯失敗;詳細信息請參閱編譯器錯誤輸出。 at org.gradle.api.internal.tasks.compile.jdk6.Jdk6JavaCompiler.execute(Jdk6JavaCompiler.java:42) at org.gradle.api.internal.tasks.compile.jdk6.Jdk6JavaCompiler.execute(Jdk6JavaCompiler.java: 33) – 2013-03-27 12:34:44
它應該使用這個JDK6類嗎?這是錯誤的來源嗎? – 2013-03-27 12:35:37