zoukankan      html  css  js  c++  java
  • SSH:dataSource配置问题

    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:p="http://www.springframework.org/schema/p"
    	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
    
    	xsi:schemaLocation="http://www.springframework.org/schema/beans 
    	http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
    	http://www.springframework.org/schema/aop 
    	http://www.springframework.org/schema/aop/spring-aop-3.0.xsd 
    	http://www.springframework.org/schema/context 
    	http://www.springframework.org/schema/context/spring-context-3.0.xsd
    	http://www.springframework.org/schema/tx 
    	http://www.springframework.org/schema/tx/spring-tx.xsd"
    	xmlns:tx="http://www.springframework.org/schema/tx">
    	<aop:config></aop:config>
    	<!-- 打开自动装配 -->
    	<context:annotation-config></context:annotation-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/mas?characterEncoding=UTF-8">
            </property>
            <property name="username" value="root"></property>
            <property name="password" value="root"></property>
        </bean>
    	

    hibernate.cfg.xml

    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE hibernate-configuration PUBLIC
              "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
              "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    
    <hibernate-configuration>
    
    	<session-factory>
    		<mapping resource="cn/edu/nwsuaf/bean/Mas.hbm.xml" />
    		<mapping resource="cn/edu/nwsuaf/bean/Course.hbm.xml" />
    		<mapping resource="cn/edu/nwsuaf/bean/Teachingplanchange.hbm.xml" />
    		<mapping resource="cn/edu/nwsuaf/bean/Highleveltalent.hbm.xml" />
    		<mapping resource="cn/edu/nwsuaf/bean/Academicdegree.hbm.xml" />
    		<mapping

    
    数据源只能在一个配置文件中配置:applicationContext.xml或者hibernate.cfg.xml。


  • 相关阅读:
    [机器学习案例1]基于KNN手写数字识别
    Android横竖屏切换View设置不同尺寸或等比例缩放的XML解决方案
    Qt之网络编程
    Redis系列-存储篇sorted set主要操作函数小结
    Code First Migrations更新数据库结构的具体步骤
    json文件解析
    go语言文件操作
    docker容器与主机之间的文件复制
    ubuntu16.04 安装docker
    Go语言string,int,int64 ,float之间类型转换方法
  • 原文地址:https://www.cnblogs.com/jasonhaven/p/7355026.html
Copyright © 2011-2022 走看看