我正在努力让cloudinary服务在我的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 {
}
答案 0 :(得分: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')
}
}