远程调用接口spring
<bean id="" class=""/>
)下面写这个是引入component的扫描组件 spa
1prototype |
<context:component-scan base-package=”com.mmnc”>
其中base-package为须要扫描的包(含全部子包) code
一、@Service用于标注业务层组件
二、@Controller用于标注控制层组件(如struts中的action)
三、@Repository用于标注数据访问组件,即DAO组件.
四、@Component泛指组件,当组件很差归类的时候,咱们能够使用这个注解进行标注。
@Service public class UserServiceImpl implements UserService { } component
@Repository public class UserDaoImpl implements UserDao { } getBean的默认名称是类名(头字母小写),若是想自定义,能够@Service(“***”) 这样来指定,这种bean默认是单例的,若是想改变,能够使用@Service(“beanName”) 接口
@Scope(“prototype”)来改变。能够使用如下方式指定初始化方法和销毁方法(方法名任意): @PostConstruct public void init() { }ci