2019 第三周 開發筆記
買了教程視頻 捋一遍 之前看的教程沒有的@WebListener
br/>@WebListener
public class RequestListener implements ServletRequestListener
上下文監聽器(資源加載)
public class CustomContextListener implements ServletContextListener
整合mybatis沒什麽復雜,
操作時候打印sql在配置文件加上mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
2019.1.15
@Transactional 事物
lsof -i:8080 查看端口占用情況
generator 使用方法
打開rapid-gen.bat
- 生成器自帶了測試數據庫,運行start_db.bat後再運行gen user_info即可生成文件
- 生成器的主要配置文件為generator.xml,裏面修改數據庫連接屬性
- template目錄為代碼生成器的模板目錄,可自由調整模板的目錄結構
templateRootDir:C:\Users\林博軒\Documents\WeChat Files\lbx345\Files\generator-hcb\generator-hcb\template
gen table_name [include_path]: generate files by table_name
del table_name [include_path]: delete files by table_name
gen [include_path]: search database all tables and generate files
del [include_path]: search database all tables and delete files
quit : quit
[include_path] subdir of templateRootDir,example: 1. dao 2. dao/,service/
please input command:
輸入命令gen 表名(t_city)
即可到處實體類/mapper/mtbatis/service2019.1.16
mac logback 日誌權限
老大更改了logback生產文件的目錄,今早項目跑不起來了,提示找不到/opt/work/logs/****.log 但同事跑起來沒問題,查找資料+問老大 解決問題。
原因:我的mac 根目錄下沒有opt文件,同事的電腦都是windows則沒有問題 因為window沒這些權限問題
解決方案 在根目錄下 sudo mkdir opt 用高權限方式新建opt文件目錄
項目就可以跑起來了2019.1.17
寫業務
case when and/or使用
SELECT package_times - play_times as times,CASE WHEN device_no=#{deviceNo} and package_times-play_times>0 THEN 1 ELSE 0 END AS STATUS FROM t_race_order WHERE user_id = #{userId} AND pay_status = 1 ORDER BY create_time DESC
mybatis 返回類型錯誤解決
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: Error instantiating interface com.hcb.cloud.mapper.race.RacePropOrderMapper with invalid types () or values (). Cause: java.lang.NoSuchMethodException: com.hcb.cloud.mapper.race.RacePropOrderMapper.<init>()
解決:返回值類型寫錯 寫成mapper了。。。
tabbitMQ 主題模式Topic
老大通俗講解:多個消費者訂閱一個主題 當主題生產了一條消息後 多個消費者都接到了 但經過訂閱著路由轉發 (實際情況是appid) 轉發到具有執行權的消費者。
百度搜索了解:rabbitMQ模式 搜的是有5種
insertUseGeneratedKeys 返回id 用法
正確用法:
RacePropOrderEntity racePropOrderEntity = RacePropOrderEntity.buildPropOrder(raceGameRequestVo);
racePropOrderMapper.insertUseGeneratedKeys(racePropOrderEntity);
return RacePropOrderIdVo.build(racePropOrderEntity.getId());
錯誤用法:該方法獲取的int指總是1 (不是id,是插入成功狀態)
int i = racePropOrderMapper.insertUseGeneratedKeys(racePropOrderEntity);
2019.1.18
上午 寫業務
一些地方增加了@async異步方法 用起來很方便
2019 第三周 開發筆記