zoukankan      html  css  js  c++  java
  • spring注解开发

    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);
    	}
    }
    

      

  • 相关阅读:
    django2自动发现项目中的url
    Python中的__name__
    阻塞与非阻塞、同步与异步、I/O模型
    Python中的关键字的用法
    元类
    数据库介绍
    django+nginx+uwsgi 项目部署
    centos7安装mysql5.6
    MySQL5.7的新特性
    Python进行MySQL数据库操作
  • 原文地址:https://www.cnblogs.com/fjkgrbk/p/spring_anno.html
Copyright © 2011-2022 走看看