How to use spring on a class situated in a library? -
although,
i'm confortable other di macwire, need project deal spring.
i'm trying integrate external library of service developing main application use spring instantiate services. i'm wondering how can such code in library treated same code in source respect spring ?
that instantiating class in library, within main source of project using spring. give path of package scan bean ?
m
spring configuration file achieve di. have understand question is, looking way use spring capabilities instantiate class. (correct me if wrong..) way instantiate bean remain same external service or own library code.
say if have classes like,
//external library class package com.test; public class helloworld{ ... } // class package com.abc; import com.test.helloworld; public class myclass{ helloworld obj; ... }
spring xml configuration file like,
<beans> <!-- external library class --> <bean id="helloworld" class="com.test.helloworld" /> <!-- class --> <bean id="myclass" class="com.abc.myclass"> <property name="obj" ref="helloworld"/> </bean> </beans>
i recommend refer 'spring dependency injection' in spring documentation..
Comments
Post a Comment