Grails Service未在集成测试中自动装配

时间:2015-11-20 10:58:54

标签: grails integration-testing

我有一个示例Grails服务并尝试在Grails的集成测试中自动连接它。尽管IntelliJ编辑器显示其自动连线,但在运行时我始终将其视为空。

集成测试如下所示,我将sampleService视为始终为null。

class Sample {

    def sampleService;

    @Test
    public void testSample() {
        println(" Hello...")
    }
}

1 个答案:

答案 0 :(得分:0)

@Autowired明确添加到我的服务后解决了问题。请参阅以下代码

class Sample {

    @Autowired
    def sampleService;

    @Test
    public void testSample(){
        println(" Hello...")
    }
}
相关问题