简体   繁体   中英

Eclipse Spring Builder set properties with Groovy beans

I typically use groovy to construct simple bean but the Spring IDE plugin to eclipse fails to build when I try to set a property that is generated by groovy without an explicit setter. For example,

class MyGrooyClass {
    def propertyA
}

and in the spring configuration file I have something that looks like:

<bean id="MyGroovyClassBean" class="MyGroovyClass">
  <property name="propertyA" value="someValue"/>
</bean>

The spring builder says there is no such property but it is in the bytecode since it is automatically generated by groovy. If I don't validate that bean, everything works, so spring can resolve the property, but it seems to be an issue with the plugin. Is there a way to work around this or to disable validating a particular bean?

EDIT: I can construct the bean using the groovy specific syntax

<lang:groovy id="..." script-source="...">
  <lang:property name="propertyA" value="someValue"/>
</lang>

but it seems odd that I should need to do this just for the plugin.

Thanks, Jeff

It definitely looks like a bug in the Spring IDE plugin. I've also had issues where the content assist does not show auto-complete for properties of a Groovy bean.

I see the same issue in the project I am working on. Consequently I do not use the Spring Validator.

As confirmed by Chris Dail, this is a bug in the Spring IDE plugin. I posted it in the Spring forums http://forum.springsource.org/showthread.php?p=271607&posted=1#post271607 and it has been fixed in the nightly build.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM