zoukankan      html  css  js  c++  java
  • 【Lolttery】项目开发日志

    项目的各种配置开始出现混乱的现象了

    在只有一个人开发的情况下也开始感受到维护一个项目的难度。

    之前明明还好用的东西,转眼就各种莫名其妙的报错,完全不知道为什么。

    今天一天的工作基本上就是整理各种配置。

    再加上之前数据库设计出现了问题,要增加一个表,改几个名字,删几个字段……真是头大

    1、gradle排除依赖

    在打war包的时候出现了spring-boot与dubbo框架自带的spring2.5.6冲突的情况,于是学会了这么一招:

    //仅在本地执行时使用,不添加到war
        providedRuntime 'org.springframework:spring:2.5.6.SEC03'
        //排除依赖
        compile(project(':client-core')) {
            exclude group:"org.springframework", module:"spring:2.5.6.SEC03"
        }

    配置写在gradle的dependencies中,将这个包排除在外,用新的spring4就好了。

    不禁吐槽dubbo是有多古老的框架嘛?为啥不支持新一代的spring啊?

    然而今天配置完后出现了找不到spring-servlet.xml配置文件的问题。明明放在一起的spring-core.xml都能找到的说。此问题留待明天解决。

    2、spring使用配置文件

    在本地环境、测试环境、生产环境的各种切换当真是非常操蛋的一件事情。

    为此做的第一件工作是统一数据源,redis、mysql等数据源都分别创建唯一的bean用spring注入。算是很基本的做法。

    这两天发现就算是每次改spring的xml文件也是个挺操蛋的事情。于是小小的尝试了一下这个标签:

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

    应该算是新增的标签,在网上搜索到的方法要活生生的写一个bean配置,这个能省事不少。

    这样直接用${prop.name}就可以添加配置咯~

    3、mybatis联合查询~

    还记得上次说的mybatis联合查询功能么,很快就用上了。

    为了能利用这个功能,我活生生的修改了数据库的结构。其实也是一开始设计的不标准。这次彻底符合2NF的设计,就可以愉快的联合查询了。

    作为这次修改的教训:

    不要把m:n的关联写到数据表里面!

    不要把m:n的关联写到数据表里面!

    不要把m:n的关联写到数据表里面!

    多建一个关联表不会死人。

    第一个联合查询的代码贴上来留作纪念~

    <resultMap type="com.xinou.lolttery.server.bean.Team" id="teamResultMap">
            <!-- 属性名和数据库列名映射 -->
            <id property="id" column="team_id"  />
            <result property="shortname" column="team_shortname"  />
            <result property="logo" column="team_logo"  />
        </resultMap>
    
        <resultMap type="com.xinou.lolttery.server.bean.MatchTeam" id="linkResultMap">
            <!-- 属性名和数据库列名映射 -->
            <id property="id" column="link_id"  />
            <result property="teamid" column="link_teamid"  />
            <result property="place" column="link_place"  />
        </resultMap>
    
        <resultMap id="appMatchList" type="com.xinou.lolttery.server.bean.result.AppMatchList">
            <id property="id" column="id" />
            <result property="zone" column="zone" />
            <result property="winner" column="winner" />
            <result property="zonename" column="zonename" />
            <result property="zonelogo" column="zonelogo" />
            <result property="matchdate" column="matchdate" />
            <result property="matchmode" column="matchmode" />
            <result property="result" column="result" />
            <collection property="teams" ofType="com.xinou.lolttery.server.bean.Team" resultMap="teamResultMap"/>
            <collection property="links" ofType="com.xinou.lolttery.server.bean.MatchTeam" resultMap="linkResultMap"/>
        </resultMap>
    
        <select id="queryByTime" parameterType="long" resultType="com.xinou.lolttery.server.bean.result.AppMatchList" resultMap="appMatchList">
            select m.*,mt.id link_id,mt.teamid link_teamid,mt.place link_place,t.id team_id,
            t.shortname team_shortname,t.logo team_logo, z.name zonename,z.logo zonelogo from
            ((lt_match m left join lt_match_team mt on mt.matchid = m.id ) left join lt_team t on t.id=mt.teamid)
             left join lt_match_zone z on m.zone = z.id where m.matchdate &lt; #{0} limit 0,20
        </select>
  • 相关阅读:
    【MySQL】学生成绩
    【MySQL】统计累计求和
    【MySQL】查询不在表中的数据
    【MySQL】排名函数
    【Python】数据处理分析,一些问题记录
    【Github】如何下载csv文件/win10如何修改txt文件为csv文件
    【Windows】github无法访问/hosts文件只能另存为txt
    【C/C++】拔河比赛/分组/招商银行
    【C/C++】金币
    【C/C++】旋转数组的最小数字/ 剑指offer
  • 原文地址:https://www.cnblogs.com/Ayanami-Blob/p/5338806.html
Copyright © 2011-2022 走看看