本人初学SSH2,当数据库只有一个表时,本人可以配置下来,并实现基本的CRUD。
现在我想在数据库里在建一张表,但是不知道如何配置applicationContext.xml 的DAO,因为已经配置了一张表的DAO,如果是更多的表,该如何配置DAO呢。还请大侠们不吝赐教,谢谢。
下面的内容是一张表的applicationContext.xml配制方法
<?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: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-3.0.xsd">
<!-- dataSource config -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="DriverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="url" value="jdbc:mysql://localhost:3306/testdb"></property>
<property name="username" value="sshtest"></property>
<property name="password" value="sshtest"></property>
</bean>
<!-- SessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>
<!-- TransactionManager 不过这里暂时没注入-->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<!-- DAO -->
<bean id="booksDao" class="com.books.dao.impl.BooksDaoImpl">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<!-- Services -->
<bean id="booksService" class="com.books.service.impl.BooksServiceImpl">
<property name="booksDao">
<ref bean="booksDao"/>
</property>
</bean>
<bean id="pagerService" class="com.books.commons.PagerService"/>