Spring使用扫描注入

applicationContext.xml
<context:component-scan base-package="com.vo"/>


Java页面
package com.vo;
import org.springframework.stereotype.Repository;
import com.cache.Request;
@Repository
public class LoginVo implements BaseVo {
		@Autowired
	private SsUserInfoDAO ssUserInfoDAO;
		public Request excute(Request request) {
			request.setResponse("返回事件");
			return request;
		}
}


PS:通过该方法后,将LoginVo对象注入到spring中,并且名称为loginVo,即可通过BeanFactory.getBean(“loginVo”)进行调用

你可能感兴趣的:(spring)