I'm usign Spring ORM with Hibernate, and when I write the command
我使用Hibernate使用Spring ORM,当我编写命令时
hibernateTemplate.save(entityInstance);
(entityInstance is obviously an instance of a User entity)
(entityInstance显然是User实体的一个实例)
I get this error:
我收到此错误:
The type org.springframework.dao.DataAccessException cannot be resolved. It is indirectly referenced from required .class files
Even though i followed a (working) tutorial step-by-step (and code-by-code) it doesn't work. This is my pom.xml
即使我一步一步地遵循(工作)教程(并且逐个代码),它也不起作用。这是我的pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.dsystems</groupId>
<artifactId>newtokenmanager</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>newtokenmanager Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>5.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.5.Final</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>5.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.45</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Eclipse also suggests me as 'quick fix' to configure build path from the menu, but I don't know exactly what to do. As some people suggested for similar issues here on SO, I tried by removing and reloading both JRE System Library and Maven dependencies, but didn't work.
Eclipse还建议我从菜单中“快速修复”配置构建路径,但我不确切知道该怎么做。正如有些人在SO上建议类似的问题一样,我尝试删除并重新加载JRE系统库和Maven依赖项,但是没有用。
3 个解决方案
#1
1
Download jar from this link
从此链接下载jar
import into your project, it will resolve.
导入到您的项目中,它将解决。
Your HibernateTemplate class is importing org.springframework.dao.DataAccessException
class which is not present in your classpath.
您的HibernateTemplate类正在导入org.springframework.dao.DataAccessException类,该类在您的类路径中不存在。
#2
1
Add in pom for Maven project
为Maven项目添加pom
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
or add jar spring-tx
或者添加jar spring-tx
#3
0
spring-tx.jar because I got this error:
spring-tx.jar因为我收到了这个错误:
The type org.springframework.dao.DataAccessException cannot be resolved. It is indirectly referenced from required .class files TestSpring.java
无法解析org.springframework.dao.DataAccessException类型。它是从所需的.class文件TestSpring.java间接引用的
spring-core.jar because I got this error:
spring-core.jar因为我收到了这个错误:
The type org.springframework.core.NestedRuntimeException cannot be resolved. It is indirectly referenced from required .class files TestSpring.java
无法解析org.springframework.core.NestedRuntimeException类型。它是从所需的.class文件TestSpring.java间接引用的
#1
1
Download jar from this link
从此链接下载jar
import into your project, it will resolve.
导入到您的项目中,它将解决。
Your HibernateTemplate class is importing org.springframework.dao.DataAccessException
class which is not present in your classpath.
您的HibernateTemplate类正在导入org.springframework.dao.DataAccessException类,该类在您的类路径中不存在。
#2
1
Add in pom for Maven project
为Maven项目添加pom
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
or add jar spring-tx
或者添加jar spring-tx
#3
0
spring-tx.jar because I got this error:
spring-tx.jar因为我收到了这个错误:
The type org.springframework.dao.DataAccessException cannot be resolved. It is indirectly referenced from required .class files TestSpring.java
无法解析org.springframework.dao.DataAccessException类型。它是从所需的.class文件TestSpring.java间接引用的
spring-core.jar because I got this error:
spring-core.jar因为我收到了这个错误:
The type org.springframework.core.NestedRuntimeException cannot be resolved. It is indirectly referenced from required .class files TestSpring.java
无法解析org.springframework.core.NestedRuntimeException类型。它是从所需的.class文件TestSpring.java间接引用的