zoukankan      html  css  js  c++  java
  • SpringMVC

    一、 db.properties 

    spring dao配置 

    <!-- 读取配置文件:数据库 -->
    <context:property-placeholder location="classpath:config/db.properties" />
    
    <!-- 配置C3P0数据源 -->
    <bean name="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="driverClass" value="${jdbc.driverClass}" />
        <property name="jdbcUrl" value="${jdbc.jdbcUrl}" />
        <property name="user" value="${jdbc.user}" />
        <property name="password" value="${jdbc.password}" />
    </bean>

    db.properties

    jdbc.driverClass=com.mysql.jdbc.Driver
    jdbc.jdbcUrl=jdbc:mysql://localhost:3306/ssm_steam?useUnicode=true&characterEncoding=utf-8&useSSL=true
    jdbc.user=root
    jdbc.password=123456

    二、 log4j.properties

    web.xml

    <!--使用监听加载log4j的配置文件-->
    <listener>
      <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>

    log4j.properties

    # Global logging configuration
    log4j.rootLogger=DEBUG, stdout
    # Console output...
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n

    三、自定义

    controller

    // 注解在成员变量上
    @Value("${dict.tagids}")
    private String tagidsId;
    @Value("${dict.platform}")
    private String platformId;

    dictTypeid.properties 文件

    dict.tagids=01
    dict.platform=02

    springmvc.xml

    <!-- springmvc配置  -->
    <context:property-placeholder location="classpath:config/dictTypeid.properties" />
  • 相关阅读:
    SSLOJ 1298.网站计划
    SSLOJ 1297.GF打Dota
    SSLOJ 1296.猫咪的进化
    脚本1)启动jetty的脚本
    mysql的常用命令
    mysql异常com.mysql.jdbc.PacketTooBigException
    debian apt-get联网安装mysql服务
    mysql 解决Warning: World-writable config file ‘/etc/my.cnf’ is ignored
    ubuntu/debian/linux彻底卸载mysql
    Ubuntu12.04_X64 apt-get install 报错404
  • 原文地址:https://www.cnblogs.com/Dm920/p/12171025.html
Copyright © 2011-2022 走看看