Injecting Annotated Bean into Regular Bean

Posted by jboyd on Stack Overflow See other posts from Stack Overflow or by jboyd
Published on 2010-06-17T14:06:01Z Indexed on 2010/06/17 14:23 UTC
Read the original article Hit count: 283

Filed under:
|
|

AppContext.xml

<bean id="myBean" class="com.myapp.MyClass">
    <property ref="myService"/>
</bean>

MyService.java

@Service
public class MyService {
 ...
}

This will throw an exception stating that no bean can be found for property "myService", which I understand because it can't be found in the context files, but I can autowire that field in other spring managed beans, but I need to explicitly build the bean in my context because the POJO is not editable in the scope of my project.

© Stack Overflow or respective owner

Related posts about java

Related posts about spring