我有一个名为 webService 的域类。当我每次尝试测试它时都会遇到相同的异常 Cannot add Service class [class ...WebService]。它不是服务!

org.codehaus.groovy.grails.exceptions.GrailsConfigurationException: Cannot add Service class [class ...WebService]. It is not a Service! 
    at grails.test.mixin.services.ServiceUnitTestMixin.mockService(ServiceUnitTestMixin.groovy:46) 
    at org.spockframework.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:138) 
    at org.spockframework.runtime.extension.builtin.JUnitFixtureMethodsExtension$FixtureType$FixtureMethodInterceptor.intercept(JUnitFixtureMethodsExtension.java:145) 
    at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:84) 
    at org.spockframework.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:138) 
|Completed 1 spock test, 1 failed in 0m 0s 

我只是想找到一些解决方法,也许有人有想法?

请您参考如下方法:

附加到类后的“服务”一词保留给 Grails Services 。这是约定优于配置原则的一部分。您所要做的就是重命名您的域类。例如,您可以将其称为 WebSrv。


评论关闭
IT序号网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!