title: Grails: Dependency injection in regular groovy class
body: <p>Let's say that I've got a BarService under grails-app/services and regular Groovy class 'Foo' like this under src/groovy.</p>
  
  <pre><code>class Foo {
    def barService
  }
  </code></pre>
  
  <p>Are there any way to turn this into a Spring bean programmatically at runtime? Just to clarify, I want to get a reference to BarService injected into the barService field.</p>
  
  <pre><code>def fooInstance = new Foo()
  magic-create-spring-bean-function(fooInstance)
  assert fooInstance.barService
  </code></pre>