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

  

上一篇:Oracle 11G 安装文档


下一篇:Scott-Knott test 配置与使用