配置分离

为了配合运维管理,同时也为了提高代码的可维护性,将一些配置相关的常量提取成配置文件。

1、JDBC相关

路总提议,jdbc连接采用tomcat自带的连接池方式,可将数据库连接性能提升50%以上。

  • 配置tomcat下的conf下的context.xml文件,在之间添加连接池配置(xxx配置根据不同环境请做修改):

       <Resource name="jdbc/mysql"

       auth="Container"          

       type="javax.sql.DataSource"          

       driverClassName="com.mysql.jdbc.Driver"          

       url="jdbc:mysql://xxx.xxx.xxx.xxx:3306/ds_client?useUnicode=true&amp;characterEncoding=utf8&amp;allowMultiQueries=true&amp;autoReconnect=true"      

       username="xxxxx"          

       password="xxxxx"          

       maxActive="100"          

       maxIdle="30"          

      maxWait="10000" />  

  • 将mysql驱动包放入tomcat的lib目录下

mysql-connector-java-5.1.36.jar

  • 配置你的应用下的web.xml中的之间加入:《注意:web.xml的这段配置不加也可以正常使用》

      <resource-ref>          

        <description>DB Connection</description>          

        <res-ref-name>jdbc/mysql</res-ref-name>          

        <res-type>javax.sql.DataSource</res-type>          

        <res-auth>Container</res-auth>          

     </resource-ref>    

  • spring配置文件使用JNDI方式注入datasource

    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean" >
    <property name="jndiName">
    <value>java:comp/env/jdbc/mysql</value>
    </property>
    </bean>

2、交由运维管理的配置文件

A、B、C端

#redis
dsRedisUrl=121.43.189.232
dsRedisPort=6379

#日志输出级别
log4j_level=INFO

#圣泽用户账号
shenze_acount=rndtest

#圣泽API查询账户余额接口
FCQueryBalanceServlet = http://if.dahanbank.cn/FCQueryBalanceServlet

#圣泽API查询可订购产品接口
FCSearchProductServlet = http://if.dahanbank.cn/FCSearchProductServlet

#圣泽API归属地查询接口
FCGetAttribution = http://if.dahanbank.cn/FCGetAttribution

#圣泽API订购流量接口
FCOrderServlet = http://if.dahanbank.cn/FCOrderServlet

#圣泽API密码修改接口
FCModifyPwdServlet = http://if.dahanbank.cn/FCModifyPwdServlet

#七牛接口(目前代码是在程序中写死)
qiniu.accessKey = 7p3epTcHRqigOOSpY-mSoTWmEJ2JWp53i54BYdYV
qiniu.secretKey = PcOYsLf0voVSUNaROOcEpu4NAAmfkHI2axrqqWa3
qiniu.callbackUrl = http://ds.xwf-id.com/api/qiniuNotify
qiniu.bucket = zliner19810812
qiniu.http.base=http://7u2klj.com2.z0.glb.clouddn.com/
qiniu.http.task=http://api.qiniu.com/status/get/prefop

小微封相关

#borgen配置
api.username=www.click-v.com
api.password=S0n1MibkXJBC9i4G6wtNSGXPV0ybYfeq
api.service.address=https://devborgen.xwf-id.com/api/CustomerApi30
api.customerId=www.click-v.com
customer.cert.file.pwd=www.click-v.com
customer.cert.file=www.click-v.com-dev.p12

#DID配置
did.username=did.xwf-id.com
did.password=pymEPdpZa3975HsG3WFpPF2TXHdIMgtg
did.service.address=https://devdid.xwf-id.com/api/CustomerApi30
did.customerId=did.xwf-id.com
did.cert.file.pwd=did.xwf-id.com
did.cert.file=did.xwf-id.com-dev.p12

#回调地址
xwf.callback.url=http://121.43.189.239:8082/ds_platform/xwf/callback

3、系统配置文件

目前使用到的

#服务器上的商品入库路径
#excel_path=/home/changlong/
excel_path=/opt/static/bstatic/import_goods/

#投放地域默认全国
default_put_path=0
#商品售价与金点之间的汇率
exchange_rate=10
#数据库批量插入更新每次入库的数量
batch_count=1000

关于汇率:

目前程序中使用情况

  • A端商品品项列表使用配置文件中
  • C端商品视频金点显示使用静态常量VideoConfigConstant.IntergralRat
  • C端关注、轮播汇率在代码中写死

猜你喜欢

转载自lihaiming.iteye.com/blog/2272490
今日推荐