我有一个弹簧启动应用程序,它利用了弹簧数据neo4j。 我在我的项目中使用以下依赖项。
当我尝试在我的项目中运行样本spock测试时,我得到以下stacktrace ...
Failed to instantiate [org.neo4j.ogm.session.SessionFactory]: Factory method 'getSessionFactory' threw exception;
nested exception is java.lang.ClassFormatError: Invalid annotation element type tag: 0x0
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.2.0.RC1.jar:4.2.0.RC1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123) ~[spring-beans-4.2.0.RC1.jar:4.2.0.RC1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018) ~[spring-beans-4.2.0.RC1.jar:4.2.0.RC1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans-4.2.0.RC1.jar:4.2.0.RC1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.0.RC1.jar:4.2.0.RC1]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304) ~[spring-beans-4.2.0.RC1.jar:4.2.0.RC1]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.0.RC1.jar:4.2.0.RC1]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) ~[spring-beans-4.2.0.RC1.jar:4.2.0.RC1]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) ~[spring-beans-4.2.0.RC1.jar:4.2.0.RC1]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:766) ~[spring-beans-4.2.0.RC1.jar:4.2.0.RC1]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:812) ~[spring-context-4.2.0.RC1.jar:4.2.0.RC1]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:521) ~[spring-context-4.2.0.RC1.jar:4.2.0.RC1]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:678) [spring-boot-1.3.0.M1.jar:1.3.0.M1]
at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:339) [spring-boot-1.3.0.M1.jar:1.3.0.M1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:274) [spring-boot-1.3.0.M1.jar:1.3.0.M1]
at org.springframework.boot.test.SpringApplicationContextLoader.loadContext(SpringApplicationContextLoader.java:102) [spring-boot-1.3.0.M1.jar:1.3.0.M1]
spock规范看起来像这样
@ContextConfiguration(loader = SpringApplicationContextLoader.class,classes = TestConfig.class)
class VisitorDomainTestSpec extends Specification {
@Autowired VisitorRepository visitorRepository
@Autowired Session session
def "visitors should be created"()
{
given: "A visitor which is saved "
Visitor visitor = getVisitor()
visitorRepository.save(visitor)
when: "We try to retrieve the visitor by name"
Visitor foundVisitor = findVisitorByProperty("name", visitor.getName()).iterator().next();
then: "We should be able to retrieve the visitor"
assertEquals( foundVisitor.id ,visitor.id)
}
我的junit测试通过了,但是当我试图在这里使用spock时我被卡住了。任何指针都会有所帮助......在我的testConfig类中,我正在连接一个InProcessServer ..