首页 > 编程语言 > 详细

spring注解开发

时间:2017-11-25 00:44:24      阅读:340      评论:0      收藏:0      [点我收藏+]

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注解开发

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!