It is not possible to embed any service annotated with @Transactional in any controller in 1.3.7

I caught the strange question of introducing granules into any service annotated with @Transactional in any controller in 1.3.7.

SyncSpInfoService:

 package test
 import org.springframework.transaction.annotation.*

 class SyncSpInfoService {
    static transactional = false
            @Transactional
    def syncSpInfoData(def dataSource)throws RuntimeException{
              ...
            }

Controller:

 package test
class SyncSpInfoController {
def syncSpInfoService
def dataSource
    def index = { 
    try{            
    syncSpInfoService.syncSpInfoData(dataSource)
    render  "Success"
    return
    }catch(RuntimeException e){
       e.printStackTrace()
       render "Error:"+e.getMessage()
       return
    }           
}

}

And start the controller if SyncSpInfoService made a mistake, then I modify it and run it again, the following errors appear: Error: test.SyncSpInfoService could not be passed to test.SyncSpInfoService

I do not understand why? Help me, thanks a lot ...

+3
source share
1 answer

Try removing the "def" in the service method parameter:

    def syncSpInfoData(datasource) {} // and you don't need the throws
0
source

All Articles