web.XML:關鍵是插入Spring的監聽
<listener> <listener-class> org.apache.myfaces.webapp.StartupServletContextListener </listener-class> </listener> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener>
Spring配置文件applicationContext.XML:這裡是把IBatis的數據源寫在Spring的文件中,使Spring和IBatis結合起來
<!-- dateSource --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName"> <value>com.mysql.jdbc.Driver</value> </property> <property name="url"> <value>jdbc:MySQL://192.168.102.19/bookadmin</value> </property> <property name="username"> <value>bookadmin</value> </property> <property name="passWord"> <value>123456</value> </property> </bean> <!-- sqlMapClient --> <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClIEntFactoryBean"> <property name="configLocation"> <value> classpath:thiz/ks/bookadmin/dao/ibatis/SqlMapConfig.XML </value> </property> </bean>
IBatis的SqlMap文件SqlMapConfig.xml和JSF的配置文件faces-config.XML:該怎麼寫還是怎麼寫。