未找到休眠和 antlr.RecognitionException [英] Hibernate and antlr.RecognitionException not found
问题描述
我想学习 Hibernate.我找到了一些教程,但我在启动项目时遇到了一个问题.这是我的pom:
I want to learn Hibernate. I found some tutorial, but I have one issue with launching the project. This is my pom:
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.2.1.jre8</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.5.Final</version>
</dependency>
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.7</version>
</dependency>
</dependencies>
这是我的课:
public static void main(String[] args) {
Session session = HibernateUtilWapro.getSessionFactory().openSession();
Query q = session.createQuery("From Employee ");
List<Employee> resultList = q.list();
System.out.println("num of employess:" + resultList.size());
for (Artykul next : resultList) {
System.out.println("next employee: " + next);
}
}
我在 Eclipse Oxygen 中将它作为 Java 应用程序运行,但出现以下错误:
I run it in Eclipse Oxygen as a Java application, but I am getting the following error:
线程main"中的异常 java.lang.NoClassDefFoundError: antlr/RecognitionException在 org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory.createQueryTranslator(ASTQueryTranslatorFactory.java:57)在 org.hibernate.engine.query.spi.HQLQueryPlan.(HQLQueryPlan.java:124)在 org.hibernate.engine.query.spi.HQLQueryPlan.(HQLQueryPlan.java:88)在 org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:190)在 org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:301)在 org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:236)在 org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1800)
Exception in thread "main" java.lang.NoClassDefFoundError: antlr/RecognitionException at org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory.createQueryTranslator(ASTQueryTranslatorFactory.java:57) at org.hibernate.engine.query.spi.HQLQueryPlan.(HQLQueryPlan.java:124) at org.hibernate.engine.query.spi.HQLQueryPlan.(HQLQueryPlan.java:88) at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:190) at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:301) at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:236) at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1800)
它需要什么依赖?非常感谢帮助
What dependency do it need? Thanks a lot for help
推荐答案
您可以尝试添加以下依赖项.它解决了我的问题.
You can try to add the following dependency. It solved my issue.
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr-complete</artifactId>
<version>3.5.2</version>
</dependency>
这篇关于未找到休眠和 antlr.RecognitionException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!