[英]@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.