我有两个java接口:
public interface ProductRevision {
String getName();
public ComponentRevision getTiedComponent();
}
public interface ComponentRevision {
String getName();
}
然后我定义了两个 Grails 域类:
class GormProductRevision implements ProductRevision {
String name
GormComponentRevision tiedComponent
}
class GormComponentRevision implements ComponentRevision {
String name
}
没有编译错误,但是当我在控制器下面调用时:
class GormProductRevisionController {
def save() {
GormComponentRevision gormComponentRevision = new GormComponentRevision()
gormComponentRevision.name = 'Component'
gormComponentRevision.save()
GormProductRevision gormProductRevision = new GormProductRevision()
gormProductRevision.name = 'Product'
gormProductRevision.tiedComponent = gormComponentRevision
gormProductRevision.save()
}
}
它抛出异常
Property 'tiedComponent' has no setter method in class 'class GormProductRevision'. Stacktrace follows:
Message: Property 'tiedComponent' has no setter method in class 'class GormProductRevision'
Line | Method
->> 2138 | setSimpleProperty in org.apache.commons.beanutils.PropertyUtilsBean
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1957 | setNestedProperty in ''
| 2064 | setProperty . . . in ''
| 858 | setProperty in org.apache.commons.beanutils.PropertyUtils
| 31 | save . . . . . . in GormProductRevisionController
| 195 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter . . . . in grails.plugin.cache.web.filter.AbstractFilter
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
| 908 | run . . . . . . . in ''
^ 619 | run in java.lang.Thread
有人可以帮助我吗?