在插件描述符的 doWithSpring Colsure 中获取应用程序配置

Getting Application Configuration in doWithSpring Colsure of Plugin Descriptor

我正在扩展 Spring oauth 插件并想为某些 类 声明 bean 我像 OAuthConfig class,我想在插件 Descriptor

的 doWithSpring 闭包中将扩展 class 声明为一个 bean
public class MyOAuthConfig extends org.scribe.model.OAuthConfig {


   public MyOAuthConfig(String key, String secret) {
    super(key, secret); 
   }

}

我想将此 class 声明为插件 bean

doWithSpring{
   passportOAuthConfig(com.mycompany.security.MyOAuthConfig){
        key = [application configuration here]
   }
}

如何在此处获取 grails 应用程序配置

您可以访问 application,这是来自 doWithSpringgrailsApplication。所以你可以这样做:

doWithSpring = {
  ...
   passportOAuthConfig(com.mycompany.security.MyOAuthConfig){
        key = application.config.someValueFromHere
   }
  ...
}