zoukankan      html  css  js  c++  java
  • Spring抽取jdbc配置文件

    引入context命名空间和约束路径

    命名空间:

    xmlns:context="http://www.springframework.org/schema/context"
    

    约束路径

    
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd
    

    引入jdbc.properties文件

    <context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder>
    

    然后就可以动态引用了

    <bean id="druidDataSource" class="com.alibaba.druid.pool.DruidDataSource">
            <property name="driverClassName" value="${jdbcdriver}"></property>
            <property name="url" value="${url}"></property>
            <property name="username" value="${username}"></property>
            <property name="password" value="${password}"></property>
        </bean>
    

    总的代码

    <?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:context="http://www.springframework.org/schema/context"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
           http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context.xsd">
    
        <context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder>
    
        <bean id="druidDataSource" class="com.alibaba.druid.pool.DruidDataSource">
            <property name="driverClassName" value="${jdbcdriver}"></property>
            <property name="url" value="${url}"></property>
            <property name="username" value="${username}"></property>
            <property name="password" value="${password}"></property>
        </bean>
    
    
    </beans>
    
  • 相关阅读:
    MySQL查询出错提示 --secure-file-priv解决方法
    导入csv文件到mysql
    Ubuntu16.04配置phpmyadmin
    TensorFlow安装(Ubuntu 16.04)
    github设置只识别指定类型的文件
    python file operations
    Ubuntu16.04 install flash plugin
    PRML读书笔记——3 Linear Models for Regression
    Ubuntu下查看机器信息
    PRML读书笔记——2 Probability Distributions
  • 原文地址:https://www.cnblogs.com/lyd447113735/p/14249146.html
Copyright © 2011-2022 走看看