3

@Transactional で注釈が付けられた任意のサービスを 1.3.7 の任意のコントローラーに Grails インジェクションすることについて、私は奇妙な質問に巻き込まれました。

SyncSpInfoService:</p>

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

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

コントローラ:

 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
    }           
}

}

コントローラーを実行し、SyncSpInfoService でエラーが発生した場合は、変更して再度実行すると、次のようなエラーが発生します: エラー:test.SyncSpInfoService を test.SyncSpInfoService にキャストできません。

なぜだろう?Plsは私を助けてくれます、thxたくさん...

4

1 に答える 1

0

サービス メソッド パラメータの「def」を削除してみてください。

    def syncSpInfoData(datasource) {} // and you don't need the throws
于 2012-05-16T08:21:25.430 に答える