【发布时间】:2015-10-03 11:06:37
【问题描述】:
我有一个使用 Hibernate 和 Maven 的 J2EE 项目。
休眠部分工作正常,我可以从几个类中做我需要的事情。 但是,当我尝试从 servlet 使用 Hibernate 工具时,我得到:
SEVERE: Servlet.service() for servlet [servlets.ImproServletTest] in context with path [/ImproDB] threw exception [Servlet execution threw an exception] with root cause
java.lang.ClassNotFoundException: org.hibernate.HibernateException
我想这指向 WEB-INF 中不可用的休眠类。 我假设我需要硬拷贝 WEB-INF 目录中的 jar 来进行排序。
但是,休眠类是通过 Maven 导入的。 我可以在 Eclipse 项目资源管理器中看到它们: “项目名称/Java 资源/库/Maven 依赖项”。 但是我的项目工作区中似乎没有这样的目录(我的意思是在我的硬盘上)。 这些罐子应该位于硬盘驱动器的什么位置? 将它们包含到 WEB-INF 中希望这能解决我的问题的最佳做法是什么?
提前致谢。
编辑: 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ImproDB</groupId>
<artifactId>ImproDB</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.10.Final</version>
</dependency>
</dependencies>
</project>
【问题讨论】:
-
我可以看看你的 pom.xml,我可以在这里做适当的处理
-
默认的 Maven 依赖范围(即根本没有
<scope>)应该这样做。
标签: eclipse hibernate maven jakarta-ee