Sqlite jdbc spring配置(备忘)

前端之家收集整理的这篇文章主要介绍了Sqlite jdbc spring配置(备忘)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

简述:

记录Spring配置sqlite

@H_301_6@<?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>

猜你在找的Sqlite相关文章