The previous and only slightly different, but will instead create objects bean annotations to create objects
one on the use of xml to achieve basic crud operations
First, the modified AccountDaoImpl
Injected with notes, no set method
Second, modify AccountServiceImpl
Injected with notes, no set method
Third, modify the file bean.xml
Constraints need to be modified, and the use of <context:component-scan base-package="com.itheima"></context:component-scan>
designated use annotations to create the object to be scanned package
<?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"
xmlns:tx="http://www.springframework.org/schema/tx"
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:component-scan base-package="com.itheima"></context:component-scan>
<!--创建QueryRunner对象-->
<bean id="queryRunner" class="org.apache.commons.dbutils.QueryRunner" scope="prototype">
<!--由于queryRunner对象用dataSource来初始化数据库连接,这里注入含参构造函数-->
<constructor-arg name="ds" ref="dataSource"></constructor-arg>
</bean>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="com.mysql.cj.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/springdb?serverTimezone=UTC&characterEncoding=utf8&useUnicode=true"></property>
<property name="user" value="root"></property>
<property name="password" value="root"></property>
</bean>
</beans>