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

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
下面就可以了.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值