开发者

Spring alias not available when running in Grails

I have a problem with Spring aliases in Grails. I have a library .jar file containing classes and Spring configuration that is not working as expected. It does work as expected when I import them f开发者_开发问答rom a standard (no Grails) Java app.

The current configuration contains this.

<bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
   <property name="contextPath" value="uk.co.company.package"/>
</bean>

<alias name="marshaller" alias="unmarshaller"/>

And fails with an error.

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'unmarshaller' is defined

Changing the configuration to the following then leads it to work as expected.

<bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
   <property name="contextPath" value="uk.co.company.package"/>
</bean>
<bean id="unmarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
   <property name="contextPath" value="uk.co.company.package"/>
</bean>

The configuration is being imported and is being read. For some reason the alias is unavailable when I try to use it. What is that reason?

This is with Grails 1.3.7 and Spring 3.0.5.


I am seeing this issue as well. You can get around it by defining the alias in the Grails resources.xml or in my case in my plugin doWithSpring closure:

springConfig.addAlias "aliasName", "beanName"

I'd expect the importBeans to import alias as well


This link might be helpful for you: http://burtbeckwith.com/blog/?p=85

It is mentioned there that aliases don't work at least when declared in the resources.xml. The post also mentions a way of declaring aliases programatically. But it seems like this post was written a while back and not sure how relevant it is with grails 1.3.7.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜