繁体   English   中英

@Autowired不起作用

[英]@Autowired doesn't work

我正在尝试使用Spock和Spring创建一个简单的集成测试。 所有必需的依赖项都存在于我的classpath-spock库和spock-spring 不幸的是,未注入underTest (我总是得到java.lang.NullPointerException: Cannot invoke method someMethod() on null object )。 请看下面的代码

@ContextConfiguration(locations=["classpath:test1.xml","classpath:test2.xml"])
class SimpleSpockIntegrationTest extends Specification {

    @Autowired
    SomeRepo underTest;

    @Transactional
    def "repo test" () {
        expected:
            underTest.someMethod(1) == 1;
    }
}

看起来spock-spring 1.1 (1.1-groovy-2.4)可能存在错误。 切换到1.0 (使用spock-core 1.1 ),一切正常。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM