0

我正在尝试让云服务在我的 grails 应用程序中工作。Cloudinary 提供了一些 java 代码,但没有插件。config.xml 如下所示:

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

1 回答 1

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')
   }
}
于 2013-10-25T01:16:42.937 回答