【Lolttery】项目开发日志 (三)维护好一个项目好难
項(xiàng)目的各種配置開始出現(xiàn)混亂的現(xiàn)象了
在只有一個(gè)人開發(fā)的情況下也開始感受到維護(hù)一個(gè)項(xiàng)目的難度。
之前明明還好用的東西,轉(zhuǎn)眼就各種莫名其妙的報(bào)錯(cuò),完全不知道為什么。
今天一天的工作基本上就是整理各種配置。
再加上之前數(shù)據(jù)庫設(shè)計(jì)出現(xiàn)了問題,要增加一個(gè)表,改幾個(gè)名字,刪幾個(gè)字段……真是頭大
##1、gradle排除依賴
在打war包的時(shí)候出現(xiàn)了spring-boot與dubbo框架自帶的spring2.5.6沖突的情況,于是學(xué)會(huì)了這么一招:
//僅在本地執(zhí)行時(shí)使用,不添加到warprovidedRuntime 'org.springframework:spring:2.5.6.SEC03'//排除依賴compile(project(':client-core')) {exclude group:"org.springframework", module:"spring:2.5.6.SEC03"} 復(fù)制代碼配置寫在gradle的dependencies中,將這個(gè)包排除在外,用新的spring4就好了。
不禁吐槽dubbo是有多古老的框架嘛?為啥不支持新一代的spring啊?
然而今天配置完后出現(xiàn)了找不到spring-servlet.xml配置文件的問題。明明放在一起的spring-core.xml都能找到的說。此問題留待明天解決。
##2、spring使用配置文件
在本地環(huán)境、測(cè)試環(huán)境、生產(chǎn)環(huán)境的各種切換當(dāng)真是非常操蛋的一件事情。
為此做的第一件工作是統(tǒng)一數(shù)據(jù)源,redis、mysql等數(shù)據(jù)源都分別創(chuàng)建唯一的bean用spring注入。算是很基本的做法。
這兩天發(fā)現(xiàn)就算是每次改spring的xml文件也是個(gè)挺操蛋的事情。于是小小的嘗試了一下這個(gè)標(biāo)簽:
<context:property-placeholder location="/config.properties"/> 復(fù)制代碼應(yīng)該算是新增的標(biāo)簽,在網(wǎng)上搜索到的方法要活生生的寫一個(gè)bean配置,這個(gè)能省事不少。
這樣直接用${prop.name}就可以添加配置咯~
##3、mybatis聯(lián)合查詢~ 還記得上次說的mybatis聯(lián)合查詢功能么,很快就用上了。 為了能利用這個(gè)功能,我活生生的修改了數(shù)據(jù)庫的結(jié)構(gòu)。其實(shí)也是一開始設(shè)計(jì)的不標(biāo)準(zhǔn)。這次徹底符合2NF的設(shè)計(jì),就可以愉快的聯(lián)合查詢了。 作為這次修改的教訓(xùn): 不要把m:n的關(guān)聯(lián)寫到數(shù)據(jù)表里面! 不要把m:n的關(guān)聯(lián)寫到數(shù)據(jù)表里面! 不要把m:n的關(guān)聯(lián)寫到數(shù)據(jù)表里面! 多建一個(gè)關(guān)聯(lián)表不會(huì)死人。 第一個(gè)聯(lián)合查詢的代碼貼上來留作紀(jì)念~
<resultMap type="com.xinou.lolttery.server.bean.Team" id="teamResultMap"><!-- 屬性名和數(shù)據(jù)庫列名映射 --><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"><!-- 屬性名和數(shù)據(jù)庫列名映射 --><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 < #{0} limit 0,20</select> 復(fù)制代碼總結(jié)
以上是生活随笔為你收集整理的【Lolttery】项目开发日志 (三)维护好一个项目好难的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 怀孕了梦到来例假怎么回事
- 下一篇: 01-gt;选中UITableViewC