ver*_*joe 11 exception-handling exception
我的源代码如下.它有一个错误,"不能抛出DataAccessException类型的异常;异常类型必须是Throwable的子类".
我无法理解为什么错误发生了.让我知道.谢谢.
package com.sds.afi.cosmos.cmm.db.impl;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.SqlMapClientTemplate;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;
import com.sds.afi.cosmos.cmm.db.MainDao;
@Repository
//@SuppressWarnings("unchecked") // ???? ????? ??? ??
public class MainDaoImpl extends SqlMapClientDaoSupport implements MainDao {
@Autowired
private SqlMapClientTemplate sqlMapClientTemplate;
@SuppressWarnings("unchecked")
@Override
public List<HashMap> getUserInfo() throws DataAccessException {
List<HashMap> lists;
lists = sqlMapClientTemplate.queryForList("common.getList");
return lists;
}
}
Run Code Online (Sandbox Code Playgroud)
man*_*shi 23
如果异常的类型层次结构中的某些类不在类路径上,则会发生这种情况.在这种情况下,它无法验证异常是否真正扩展了Throwable,无论是否是已检查的等等.因此错误.例如,Dataaccessexception的超类:类路径中可能缺少NestedRuntimeException,因为它位于不同的jar中,即spring-core.
| 归档时间: |
|
| 查看次数: |
31488 次 |
| 最近记录: |