I have this xml config
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:lang="http://www.springframework.org/schema/lang"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd">
<lang:groovy id="foo" script-source="${groovyBeanLocation}"/>
</beans>
I imported this config in my ApplicationConfig, but do not want to mix several types of configurations (java and xml).
How can I make a given configuration using java?
If you're using a Groovy class as a Spring bean, you don't need the <lang:groovy> tag at all. Just deploy your compiled class as though it was Java, and it should just work as long as you include the groovy-all jar file as a project dependency.
The <lang:groovy> tag with a script-source is for "refreshable" beans. That's where you deploy the source code (rather than the compiled version), and Spring detects changes and recompiles for you. It's how you can update code in a running application, which is cool but pretty rare.
If all you want to do is write your implementation classes in Groovy, just compile them as usual and add them to the JavaConfig files the way you would any other bean. It's all bytecodes to Spring.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With