Eclipse Spring Builder set properties with Groovy beans - eclipse

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.

Related

Is there a value for the Sprint Boot #ConfigurationProperties compatible with both Eclipse IDE and InteliJ IDEA?

Having a simple Sprint Boot application with the health actuator endpoint enables, allows you to specify and bind such a property in application.properties (in one of the following accepted ways):
# Eclipse IDE
management.endpoint.health.show-details=when-authorized
# or
# InteliJ IDEA
management.endpoint.health.show-details=when_authorized
The value of this property is one of an Enum type.
Both variants are accepted because of the Relaxed Binding feature of Spring Boot #ConfigurationProperties annotations.
While both values are valid from Spring and Maven build point of view, each of the two IDEs will only suggest (auto-completion, hover-documentation, ctrl-click-navigate-to-definition) their own version of value of the property and report an error if the other one is used.
Is there a way to make both world happy?
It's a known issue in IDEA. Please vote/follow: https://youtrack.jetbrains.com/issue/IDEA-171730
Found a version that makes everyone (almost) happy (Maven, InteliJ IDEA, Eclipse):
management.endpoint.health.show-details=WHEN_AUTHORIZED
The Spring Boot implementation defines it like this and using this form, almost everyone is happy.
Eclipse IDE
* if you type "W", the auto-completion will follow capitalised
* both hover documentation and code navigation work
InteliJ IDEA
* auto-completion will never suggest the capitalised version (but it will not show an error when using it)
* both hover documentation and code navigation work
and Maven does not care since Spring Boot is using the relaxed binding rules here.

Spring Annotation-based Project Templates

I am new to Spring. I am learning it from different sources. Spring Recipes, Spring In Action and Spring documentation. According to Spring 3.+, XML configuration can be ignored at all. This is good for me as a beginner.
Problem:
I am using Spring Tool Suite, is there a Spring Web project template that starts with annotations only? All the project templates I have found use XML configuration. I don't even know where to put my DispatcherServlet. I don't know where to put my controllers.
I also had the same problem when Starting out with Spring to find only annotation based templates. Then I found this from John Thompson. This project is completely annotation based and the only xml file involved is pom.xml
I recommend you to run through Spring Guides - they are up to date and use annotation based configuration.
This is guide how to make a restfull web service using spring-boot. It has description how to made project with maven, gradle or STS.
The official recommendation is to base all new projects on Spring Boot which is XML-less out of the box.
STS offers a nice integration with the Spring Initializr service: just go to "New -> Spring Starter Project", fill in a few fields like project name etc. and tick the boxes next to modules you're interested in.

Facing Spring Roo issue while converting JPA project to non-JPA project

I have a Spring - JPA project generated using Spring Roo. Now for some requirement we are replacing our JPA layer with some other framework (MyBatis) which is not JPA-compliant. I have done the changes and they are working fine also. I have removed all the JPA dependencies from my pom.xml file.
I am facing issues with my JUnit test project which is used to test DAO layer. Spring Roo is looking for the javax.persistence.Entity class which is part of JPA specific jar.
Please find below the error details below:
can't determine annotations of missing type javax.persistence.Entity
when weaving type ****.**.***Test
when weaving classes
when weaving
when batch building BuildConfig[null] #Files=12 AopXmls=#0
[Xlint:cantFindType]
error at (no source information available
Can anyone please advise me how to remove this error without adding a JPA dependency?
You could try to make a push-in from your test .aj file to the related .java file and then remove the necessary code (imports, annotations) that makes that your Spring Roo shell shows that error.
If you are not sure about how to make a push-in, you could read Spring Roo 1.3.2.RELEASE documentation http://docs.spring.io/spring-roo/docs/1.3.2.RELEASE/reference/html/removing.html#removing-step-by-step-1
Regards,

Spring AOP using AspectJ LTW not working

I am using spring aop and have defined some aspects. Spring LTW is enabled on my tomcat.
In my application context:
<context:load-time-weaver/>
<aop:aspectj-autoproxy proxy-target-class="false"/>
Aspects are working fine too! but the target class is proxied! causing ClassCastException: can not convert $Proxy...
Note that I don't my target classes to be proxied!
If you are using AspectJ LTW you only need the tag
<context:load-time-weaver/>
in your Spring context file. So you can remove,
<aop:aspectj-autoproxy proxy-target-class="false"/>
If the target class is proxied is because LTW with AspectJ is not configured in a good way, for this reason is not AspectJ who is handling your advices, and is Spring who is doing that. For this reason you see proxy based target class.
Check this links,
http://static.springsource.org/spring/docs/3.2.2.RELEASE/spring-framework-reference/html/aop.html#aop-aj-ltw
http://static.springsource.org/spring/docs/3.2.2.RELEASE/spring-framework-reference/html/aop.html#aop-aj-ltw-environments

Spring IDE / STS : Can I get autocompletions of beans from other files?

When writing XML beans and using "ref=" everything works well as long as beans are declared in one file. But when bean is in other file, I can't get any autocompletion.
Doesn't work in Spring Tools Suite 2.8.1 or Eclipse 3.7.1 with Spring IDE plugin.
Either import the other file or create a config set that groups all the files.
Spring/Eclipse 'referenced bean not found' warning when using <import>?