2
我在Spring Async注释的服务方法中持久存在Grails域对象时遇到问题。在Spring的“Async”注释方法不起作用的Grails持久性
下面是简化代码:
class DocumentService {
@Async
def process(Long documentId, Organization organization) {
...
def organizationCari = new OrganizationCari(organization: organization, active: true)
organizationCari.save(flush: true, failOnError: true)
print "Document processing..."
...
print "Document processed..."
}
}
我有方法异步运行,但我似乎无法得到任何东西印在控制台上,因为线程在保存操作结束。我没有得到任何错误,域对象仍然没有保留。
删除Async注解解决了这个问题,但我必须异步运行该方法。
我在Spring 3.1.2中使用了Grails 2.1.1。