简述:
记录Spring配置sqlite
<?xml version="1.0" encoding="UTF-8"?> <!-- 指定Spring配置文件的Schema信息 --> <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-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"> <!-- 定义数据源Bean--> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <!-- 指定连接数据库的驱动 --> <property name="driverClassName" value="org.sqlite.JDBC" /> <!-- 指定连接数据库的URL --> <property name="url" value="jdbc:sqlite:C:/Users/anialy/Desktop/workspace/MyProj/db/MY_DB" /> </bean> <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource"> <ref local="dataSource" /> </property> </bean> <bean id="appDao" class="com.anialy.myproj.dao.AppDao"> <property name="jdbcTemplate"> <ref local="jdbcTemplate" /> </property> </bean> <bean id="versionDao" class="com.anialy.myproj.dao.VersionDao"> <property name="jdbcTemplate"> <ref local="jdbcTemplate" /> </property> </bean> </beans>
在web.xml中添上
<listener> <listener-class>org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:applicationContext-dao.xml </param-value> </context-param>原文链接:https://www.f2er.com/sqlite/200941.html