2013-10-25 76 views
0

我試圖讓cloudinary服務在我的grails應用程序中工作。 Cloudinary提供了一些java代碼,但沒有插件。 config.xml文件看起來是這樣的:將java config.xml轉換爲grails config.groovy

<bean id="cloudinaryConfigMap" class="java.util.HashMap"> 
     <constructor-arg> 
      <map key-type="java.lang.String" value-type="java.lang.String"> 
       <entry key="api_key" value="${cloudinary.api.key}" /> 
       <entry key="api_secret" value="${cloudinary.api.secret}" /> 
       <entry key="cloud_name" value="${cloudinary.cloud-name}" /> 
       <entry key="callback" value="$[app.url.base]/path/to/cloudinary_cors.html" /> 
      </map> 
     </constructor-arg> 
    </bean> 

    <bean id="cloudinary" class="com.cloudinary.Cloudinary"> 
     <constructor-arg index="0" ref="cloudinaryConfigMap" /> 
    </bean> 

    <bean id="cloudinarySingleton" class="com.cloudinary.SingletonManager" 
     init-method="init" destroy-method="destroy"> 
     <property name="cloudinary" ref="cloudinary" /> 
    </bean> 

怎麼會是這樣的Config.groovy中重寫?與開始:

bean { 
} 

回答

0

試試這個:

import com.cloudinary.Cloudinary 
import com.cloudinary.SingletonManager 

beans = { 

    cloudinaryConfigMap(HashMap, 
     [api_key: "${cloudinary.api.key}", 
     api_secret: "${cloudinary.api.secret}", 
     cloud_name: "${cloudinary.cloud-name}", 
     callback: "$[app.url.base]/path/to/cloudinary_cors.html"]) 

    cloudinary(Cloudinary, ref('cloudinaryConfigMap')) 

    cloudinarySingleton(SingletonManager) { bean -> 
     bean.initMethod = 'init' 
     bean.destroyMethod = 'destroy' 
     cloudinary = ref('cloudinary') 
    } 
}