title: Injecting Spring Beans to Groovy Script
body: <p>I've seen many examples about Groovy objects as Spring beans but not vice versa. I'm using Groovy in a Java EE application like this:</p>
  
  <pre><code>GroovyCodeSource groovyCodeSource = new GroovyCodeSource(urlResource);
  Class groovyClass = loader.parseClass(groovyCodeSource, false);
  return (GroovyObject) groovyClass.newInstance();
  </code></pre>
  
  <p>In this way, classes written in Groovy with <code>@Configurable</code> annotation are being injected with Spring beans. It's OK for now.</p>
  
  <p>How can I get the same by using <code>GroovyScriptEngine</code>? I don't want to define a class and I want it to work like a plain script. Is Spring/Groovy capable of that?</p>
  
  <p>I've seen a post about this but I'm not sure whether it answers my question or not:</p>
  
  <p><a href="https://stackoverflow.com/questions/14957980/spring-inject-autowire-a-groovy-class-that-is-created-at-runtime#comment21079319_14972681">HERE</a></p>