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" />
原文地址:https://www.cnblogs.com/Dm920/p/12171025.html