Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Grails服务未在集成测试中自动连接_Grails_Integration Testing - Fatal编程技术网

Grails服务未在集成测试中自动连接

Grails服务未在集成测试中自动连接,grails,integration-testing,Grails,Integration Testing,我有一个示例Grails服务,并试图在Grails的集成测试中自动连接它。尽管IntelliJ编辑器显示其自动连接,但在运行时,我总是将其设置为null 集成测试如下所示,其中我sampleService始终为空 class Sample { def sampleService; @Test public void testSample() { println(" Hello...") } } 将@Autowired明确添加到我的服务后,问题

我有一个示例Grails服务,并试图在Grails的集成测试中自动连接它。尽管IntelliJ编辑器显示其自动连接,但在运行时,我总是将其设置为null

集成测试如下所示,其中我sampleService始终为空

class Sample {

    def sampleService;

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

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

class Sample {

    @Autowired
    def sampleService;

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

您是在扩展
规范
(Grails3)还是
集成规范
(Grails2)?我不扩展任何规范,而是使用Grails2.2.4