欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

配置HIBERNATE源码的时候出错的解决办法 HibernateAntjunitEclipseJava 

程序员文章站 2022-07-05 09:56:04
...
All right, time to build. Window... Show View... Ant opens the Ant GUI. The left-most icon (an ant being crushed to ick by a "+") lets me import a build file. I select build.xml; Eclipse thinks for a moment, then adds a line with a red error marker to the Ant view. Hmm... what's this? Click on it, and it shows the error message:

build.xml:35: taskdef A class needed by class org.apache.tools.ant.taskdefs.optional.junit.JUnitTask cannot be found; junit/framework/Test

Welcome to the wonderful world of plug-and-fail software. As part of the build process, Ant wants to run some JUnit tests. The rather cryptic message shown above is its way of saying that it can't find the Ant plugin (not Eclipse plugin---Ant plugin) that it needs to do this. JUnit is there, but we need to tell Ant how to find it.

So, go to Window... Preferences... Ant... Runtime, select Ant Home Entries, select "Add JARs", navigate to lib/junit.jar, and click "OK". (I got a warning about Ant not being able to find tools.jar when I did this; I ignored it.) Once that's done, go back to the Ant view inside Eclipse, right click in the pane, and select "Refresh Buildfiles". If all has gone well, the error marker disappears.

probably a problem will occur .for example:java.lang.NoClassDefFoundError: antlr/Tool  do under this line. you can concrect it;

copy lib/antlr-*.jar and lib/junit-*.jar in to your local ant distribution and then you can use "pure" ant
OR (which is what i recommend)
you use build.bat/sh which runs with just the libraries distributed with hibernate.

antlr/Tool的解决办法是说,把当前hibernate项目中的antlr-2.7.6rc1文件也加到Window... Preferences... Ant... Runtime中去。

在运行hibernate源码测试的时侯,还会报一个
org.hibernate.HibernateException: The dialect was not set. Set the property hibernate.dialect.
at org.hibernate.dialect.Dialect.getDialect(Dialect.java:610)
at org.hibernate.test.TestCase.buildSessionFactory(TestCase.java:55)
at org.hibernate.test.TestCase.setUp(TestCase.java:140)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)

是因为少一个hibernate.properties文件的原因,把项目  etc下面的拷贝到bin
下面就可以了.