Skip to content

Instantly share code, notes, and snippets.

@sergiomichels
Created July 23, 2013 14:11
Show Gist options
  • Select an option

  • Save sergiomichels/6062659 to your computer and use it in GitHub Desktop.

Select an option

Save sergiomichels/6062659 to your computer and use it in GitHub Desktop.
Hook into the mssageSource declaration
import org.codehaus.groovy.grails.context.support.PluginAwareResourceBundleMessageSource
import com.wordpress.sergiosmind.i18n.ExposedKeysMessageSource
class MyGrailsPlugin {
...
def doWithSpring = {
def beanconf = springConfig.getBeanConfig('messageSource')
def beandef = beanconf ? beanconf.beanDefinition : springConfig.getBeanDefinition('messageSource')
if (beandef?.beanClassName == PluginAwareResourceBundleMessageSource.class.canonicalName) {
//just change the target class of the bean, maintaining all configurations.
beandef.beanClassName = ExposedKeysMessageSource.class.canonicalName
}
}
...
}
@alex-shamshurin

Copy link
Copy Markdown

Now it does not work anymore with Grails 3.3

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:240)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1193)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1095)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment