找不到Spring dao类org.springframework.dao.DuplicateKeyException [英] Spring dao class not found org.springframework.dao.DuplicateKeyException
问题描述
我正在尝试使用 jdbcTemplate.query
,但出现类未找到错误。我正在使用spring-dao 2.0.8,并在库中查找,确实找不到任何 DuplicateKeyException
类。来自 maven存储库,这似乎是spring-dao的最新版本。
I am trying to use a jdbcTemplate.query
and I get the class not found error. I am using spring-dao 2.0.8 and looked inside the library and couldn't find any DuplicateKeyException
class indeed. From maven repository this seems to be the latest release for spring-dao.
我得到错误的代码是:
ResultSet resultSet = (ResultSet)jdbcTemplate.query (query, new ResultSetExtractor<ResultSet>() {
@Override
public ResultSet extractData(ResultSet rs) throws SQLException, DataAccessException {
return rs;
}
});
堆栈:
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/dao/DuplicateKeyException
at org.springframework.jdbc.support.JdbcAccessor.getExceptionTranslator(JdbcAccessor.java:99)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:407)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:456)
at DAO.MySQLAccess.getAccounts(MySQLAccess.java:95)
Caused by: java.lang.ClassNotFoundException: org.springframework.dao.DuplicateKeyException
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 7 more
这不是最新版本还是为什么首先给出错误?
Isn't this the latest release or why is it giving the error in the first place?
推荐答案
听起来像您的类路径中缺少一个jar。我猜你不是在使用Maven。
Sounds like you have a jar missing from the classpath. I guess you're not using maven.
我搜索了包含此类的jar并提出了这个方案。
http://mavenhub.com/c/org/springframework/dao/DuplicateKeyException/jar
I searched for jars containing this class and came up with this.
http://mavenhub.com/c/org/springframework/dao/DuplicateKeyException/jar
看起来您需要org.springframework.transaction jar。或者使用maven,它应该可以为您解决依赖性。
Looks like you need the org.springframework.transaction jar. Or use maven and it should work out your dependencies for you.
这篇关于找不到Spring dao类org.springframework.dao.DuplicateKeyException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!