Spring 使用Annotation完成bean的配置

阅读更多
------------了解 Annotation------------------
Annotation 中:
时机:不想在xml中配置bean , 则可以给我们的类加上spring组件注解,然后配置下spring的扫描器就可以实现bean 的自动载入。

spring 2.5之后引用了更多典型化注解:
@Component :是所有管理组建的通用形式
@Service :服务专用的
@Controller :控制层
@Repository :DAO层专用

使用annotation 配置步骤:
1、在xml中配置如下:
方式一:不使用默认的filter

	
	
	
		
		
		
		
		
			
			
			
			
					
			
		
	

	方式二:使用默认的filter,并使用spring中的filter资源进行过滤:
	
	
	
		
		
		
		
		
			
			
			
			
				
		
	

你可能感兴趣的:(spring,bean,annotation)