码迷,mamicode.com
首页 > 编程语言 > 详细

spring注解开发

时间:2017-11-25 00:52:55      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:public   nts   ase   override   rri   service   --   ann   组件   

applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:c="http://www.springframework.org/schema/c"
	xmlns:p="http://www.springframework.org/schema/p"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
   xsi:schemaLocation="http://www.springframework.org/schema/beans 
						http://www.springframework.org/schema/beans/spring-beans.xsd
						http://www.springframework.org/schema/context
						http://www.springframework.org/schema/context/spring-context.xsd
						http://www.springframework.org/schema/aop
						http://www.springframework.org/schema/aop/spring-aop.xsd
						http://www.springframework.org/schema/tx 
						http://www.springframework.org/schema/tx/spring-tx.xsd">
	
       <!-- 引入注解解析器 -->
       <context:annotation-config />
       <!-- 组件扫描 -->
	   <context:component-scan base-package="com.baidu.test"/>
</beans>

  UserService  

public interface UserService {
	public abstract void login();

}

  

  UserServiceImp

@Component("UserService")
public class UserServiceImp implements UserService{
	@Value("zhan")
	private String name;
	
	@Override
	public void login() {
		System.out.println("login.....");
		System.out.println(name);
	}
}

  

spring注解开发

标签:public   nts   ase   override   rri   service   --   ann   组件   

原文地址:http://www.cnblogs.com/fjkgrbk/p/spring_anno.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!