Java <;jdbc:嵌入式数据库>;in context.xml不起作用。要启动用于单元测试的sql脚本吗

Java <;jdbc:嵌入式数据库>;in context.xml不起作用。要启动用于单元测试的sql脚本吗,java,spring,hibernate,junit,Java,Spring,Hibernate,Junit,这是我的上下文文件: org.hibernate.dialogue.hsql方言 创造 真的 真的 我得到这个错误 Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 11 in XML document from class path resource [PersistenceHelper-context.xml] is invalid; nested exceptio

这是我的上下文文件:


org.hibernate.dialogue.hsql方言
创造
真的
真的
我得到这个错误

Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 11 in XML document from class path resource [PersistenceHelper-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 11; columnNumber: 64; <Line 11, Column 64>: XML-24500: (Error) Can not build schema 'http://www.springframework.org/schema/jdbc' located at 'http://www.springframework.org/schema/jdbc/spring-jdbc.xsd'
这是我现在的配置文件。我所做的只是添加一个版本,并移动一些声明:



其余的都是一样的。

你能确认你的类路径中有spring jdbc jar吗

通过移动定义xmlns:jdbc=”来修复这个问题http://www.springframework.org/schema/jdbc并在定义中添加版本号“spring-jdbc-3.0.xsd”

只需完成这些答案,这就是适合我的上下文(Spring 3.2.1):



是的,我可以。我正在使用intelliJ,我在我的lib文件夹中看到了它。哦,好吧,那么你错过了
,我假设你有它,你正在显示一个没有顶部的片段。关于您的新问题-我认为这是因为sql脚本文件的内容有问题。我看到的另一个问题是,您已将嵌入式数据源命名为“embedded”,但您的Initializer是针对名为
datasource
的数据源运行的,这是否正确?理想情况下,您希望仅针对嵌入式数据源运行脚本,对吗?我高度怀疑这是我的sql脚本,因为在我开始将spring框架引入我们的程序之前,它已经运行了很多次。你能解释一下你说的第二部分是什么意思吗?我的数据源保存Hibernate数据库的适当值来创建它(“我想在这里使用单词schema,但我不完全确定它是否是这样的”)。sql脚本具有要插入到这些表中的值。理想情况下,我希望创建表,然后对表运行脚本以填充它,如果这有意义的话。谢谢!!当我添加:xmlns:jdbc=”“xsi:schemaLocation=”“时,它成功了!!非常感谢。
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean   with name 'org.springframework.jdbc.datasource.init.DataSourceInitializer#0': Invocation of init method failed; nested exception is org.springframework.dao.DataAccessResourceFailureException: Failed to execute database script; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement at line 1 of resource class path resource []: bin
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean