关于spring的注入类型有三种:
a)setter,(重要的)
<?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"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd">
<bean id="serviceLogging" class="com.pb.aop.ServiceLogging"></bean>
<bean id="userService" class="com.pb.service.UserService"></bean>
</beans>
b)构造方法(可以忘记,但是有印象)
若构造方法中有多个参数,需要用索引进行标记注入或者类型进行标记注入。
<constructor-arg index="0" value="7500"></constructor-arg>
<constructor-arg index="1" value="75"></constructor-arg>
c)接口注入(不推荐使用)