spring 注解开发
在配置文件中引入约束
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" 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"></beans>
扫描包
<!--指定注解扫描包-->
<context:component-scan base-package="com.kuang.pojo"/>
在指定包上增加注释
@Component("user")
// 相当于配置文件中<bean id="user" class="当前注解的类"/>
public class User {
public String name = "秦疆";
}