工作日记
2017年
1
使用完毕后记得回收
list.clear(); list=null;2
UPDATE products SET goods_number = goods_number+10 ORDER BYgoods_id DESC LIMIT 5,10
上面这句测试了是错误的,MYSQL的UPDATE语句不能更新限制从第几条到第几条!
3
MySQL SQL GROUP BY是如何选择哪一条数据留下的?
INSERT INTO test1 (a, b) SELECT asset_id, substring_index( group_concat(hd_flag ORDER BY hd_flag), ',', 1 )FROM idass_uls_icds_asset_video iGROUP BY i.group_asset_id
4
SELECT a.*FROM isearch_asset aWHERE EXISTS ( SELECT 1 FROM isearch_column_asset_extend c WHERE c.asset_id = a.assetId AND c.vsite_code = 'baidu-f_1' )
**改为**
SELECT a.*FROM isearch_asset aINNER JOIN (select DISTINCT b.asset_id,b.vsite_code from isearch_column_asset_extend b where b.vsite_code = 'baidu-f_1') c ON c.asset_id = a.assetId
5
submit全部改成button 防止直接提交
6
将个数与月份一一对应
SELECT CONCAT(?,'年',b.time,'月')time,m.death as death, m.cound as coundFROM (select (DATE_FORMAT(n.happen_date,'%m'))as happen_date,sum(n.death) as death,count(n.id)as cound from sg_baseinfo n where 1=1 and if (? ='' ,DATE_FORMAT(n.happen_date,'%Y')= DATE_FORMAT(now(),'%Y') ,DATE_FORMAT(n.happen_date,'%Y') = ?) and n.sg_place like (case when ? = '' then n.sg_place else ? end) group by DATE_FORMAT(n.happen_date,'%Y-%m')) mRIGHT JOIN (SELECT '01' as time from DUAL UNION ALL SELECT '02' as time from DUAL UNION ALL SELECT '03' as time from DUAL UNION ALL SELECT '04' as time from DUAL UNION ALL SELECT '05' as time from DUAL UNION ALL SELECT '06' as time from DUAL UNION ALL SELECT '07' as time from DUAL UNION ALL SELECT '08' as time from DUAL UNION ALL SELECT '09' as time from DUAL UNION ALL SELECT '10' as time from DUAL UNION ALL SELECT '11' as time from DUAL UNION ALL SELECT '12' as time from DUAL )b on b.time = m.happen_dategroup by b.time
2018年
产品product服务(基于dubbo和zookeeper)无法启动,dubbo无法注册上去,此服务通过main方法启动。通过debug日志发现实体类,get,set方法写错方法名
7.25
1
产品product服务(基于dubbo和zookeeper)无法启动,dubbo无法注册上去,此服务通过main方法启动。
打开debug日志,报错日志如下:$$2018-07-25 09:16:34|main-SendThread(192.168.50.102:2181)|org.apache.zookeeper.ClientCnxn|INFO|org.apache.zookeeper.ClientCnxn$SendThread.logStartConnect(ClientCnxn.java:975)|Opening socket connection to server 192.168.50.102/192.168.50.102:2181. Will not attempt to authenticate using SASL (unknown error)##09:16:34|main-SendThread(192.168.50.102:2181)|org.apache.zookeeper.ClientCnxn|DEBUG|org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1086)|An exception was thrown while closing send thread for session 0x162a2d9eb5782d5 : Unable to read additional data from server sessionid 0x162a2d9eb5782d5, likely server has closed socket##
事后证明为MQ的问题。重启MQ以后正常注册服务。
2 数据库权限应选择第二句
GRANT ALL ON "public"."tbl_investor_borrow_backup" TO "htt";ALTER TABLE "public"."tbl_investor_borrow" OWNER TO "htt";
3
测试压测发现借款人发起的借款与投资人收到的借款请求不一致。原有是通过MQ事件的方式,现在通过直接调用dubbo接口。事件在大流量模式下并不可靠。
4
提交测试发布到测试环境时,发现一页面进不去,看日志没有报错。方法也全部运行完毕,就是不进页面。查看tomcat下的jsp日志,发现有中文字符。
D:\apache-tomcat-7.0.55\logs\localhost.2018-05-12.log8.1
public void loanVerify(long userId, int status, String link, JSONObject result, String code, String loanAmount, int loanType, String pledgeAmount) {
刚接手网站服务,发现发送短信的接口参数过长,可以使用建造者模式。封装一个对象,可以实现不定参数。因为参数基本都相似,比如userId,loanId,applyID等等
8.17
Integer flagSx=qualifiedSX.getStatus();Integer flag=2;if(flag.equals(flagSx)){}//或者if(flagSx.equals(2)){}
2.Map<String,Object> map=
map.get(16)为null 3.测试bug前端比较多,接口没有测试用例,也就没有测试8.30
1数据错误引起前台无法提交,无任何报错
{ "value": [{ "unit": "万元/年", "status": "解锁", "value": "4.2", "label": "固定薪酬", "itemCode": "136" }, { "unit": "万元/年", "status": "解锁", "value": "3.7", "label": "浮动薪酬", "itemCode": "137" }, { "value": "0", "label": "经营利润", "itemCode": "138" }, { "value": "0", "label": "股权分红", "itemCode": "139" }]}
正确为
{ "value": [{ "unit": "万元/年", "status": "解锁", "value": "4.2", "label": "固定薪酬", "itemCode": "136" }, { "unit": "万元/年", "status": "解锁", "value": "3.7", "label": "浮动薪酬", "itemCode": "137" }]}
2查出表prod_user_qualified中(qualified_cate_id=2按用户分组的最新一条记录的status=3时)且(qualified_cate_id=4按用户分组的最新一条记录的status=3时)的记录
SELECT p1. ID FROM ( SELECT t1. ID, t1.user_id FROM "public"."prod_user_qualified" t1 INNER JOIN ( SELECT T .user_id, MAX (T . ID) AS ID FROM "public"."prod_user_qualified" T WHERE T .qualified_cate_id = 4 GROUP BY T .user_id ) t2 ON t1. ID = t2. ID AND t1.status = 3 ) p1 INNER JOIN ( SELECT t1. ID, t1.user_id FROM "public"."prod_user_qualified" t1 INNER JOIN ( SELECT T .user_id, MAX (T . ID) AS ID FROM "public"."prod_user_qualified" T WHERE T .qualified_cate_id = 2 GROUP BY T .user_id ) t2 ON t1. ID = t2. ID AND t1.status = 3 ) p2 ON p1.user_id = p2.user_id
9.27
HttpServletRequest request.setAttribute
在action层只能用getAttribute取11.7
更新操作不能用实体类更新。最好一个方法只更新一个字段,便于查找问题
11.8
@Resource(name="threadPool") private ThreadPoolTaskExecutor taskExecutor;
for(MessageQueueEntity queueItem : list){ taskExecutor.execute(new InnerRunnable(queueItem,this)); }
private static class InnerRunnable implements Runnable{ private MessageQueueEntity mqe; private SendMessageJob sendMessageJob; public InnerRunnable(MessageQueueEntity mqe,SendMessageJob sendMessageJob){ this.mqe = mqe; this.sendMessageJob = sendMessageJob; } @Override public void run() { this.sendMessageJob.dealQueueItem(this.mqe); } }
private static ExecutorService executorService = Executors.newFixedThreadPool(50);//同上
Spring中@Async注解实现“方法”的异步调用
sping 中定时任务的实现大概有三种- ava自带的java.util.Timer类 2.使用Quartz 3.spring-task-->@Scheduled(cron = "1/10 * * * * ?") 前后端分离,就是把jsp页面的逻辑全部放到后台,后端的工作量还是没变。
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true)@Transactional
11.9
Remove this dangerous instance of double-checked locking
public static String dialectClass = null; public static Dialect buildDialect(Configuration configuration) { if (dialectClass == null) { synchronized (DialectFactory.class) { if (dialectClass == null) { dialectClass = configuration.getVariables().getProperty("dialectClass"); } } }
改为
public static Dialect buildDialect(Configuration configuration) { if (dialectClass == null) { init(configuration); } Dialect dialect = null; try { dialect = (Dialect) Class.forName(dialectClass).newInstance(); } catch (Exception e) { logger.error("请检查 mybatis-config.xml 中 dialectClass 是否配置正确?" + e.getMessage(), e); } return dialect; } private static synchronized void init(Configuration configuration){ if (dialectClass == null) { dialectClass = configuration.getVariables().getProperty("dialectClass"); } }
protected Logger logger = LogManager.getLogger(this.getClass());protected static Logger logger = LogManager.getLogger(MessageFileSupport.class);//静态方法引用
public interface MessageQueueService { ListNOT_FETCH_LOCK_OBJ = new ArrayList<>();
Mutable fields should not be "public static"
11.14
commons-email-1.4.jar
javax.mail-1.5.2.jarpublic class mail { public static void main(String[] args) { MultiPartEmail mail = new MultiPartEmail (); mail.setHostName("192.168.10.30"); mail.setAuthentication("test@hongtiantao.com", "fhAS"); mail.setCharset("UTF-8"); try { mail.setFrom("test@hongtiantao.com", "红天桃客户服务"); mail.addTo("179691@qq.com","Chrome"); mail.setSubject("待办事务提醒"); mail.setMsg("A" + "有一条新记录" + "Z" + "等待审核"); mail.setStartTLSEnabled(true); mail.setSmtpPort(587); mail.send(); } catch (EmailException e) { e.printStackTrace(); } }
JDK1.7无法运行,报错为PKIX:unable to find valid certification path to requested target,更换1.8后正常运行。
更换后报错 java.lang.RuntimeException: java.io.IOException: invalid constant type: 15,需单独指定javassist 包版本,升级为3.20.0-GA问题解决。 POP3收邮件,SMTP发邮件 ------------------------------------- org.I0Itec.zkclient11.16
错误操作
Listlist=new ArrayList (); list.add("1"); list.add("2"); list.add("3"); list.add("4"); for(String map : list){ if("3".equals(map)){ list.remove(map);} System.out.print(map);//代表业务逻辑 } for(String map : list){ System.out.print(map); }
123124
4没打印出来- 客户端请求提交到DispatcherServlet
- 由DispatcherServlet控制器查询一个或多个HandlerMapping,找到处理请求的Controller
- DispatcherServlet将请求提交到Controller
- Controller调用业务逻辑处理后,返回ModelAndView
- DispatcherServlet查询一个或多个ViewResoler视图解析器,找到ModelAndView指定的视图
- 视图负责将结果显示到客户端
启动服务
@SuppressWarnings("resource") public static void main(String[] args) throws InterruptedException { logger.info("启动我的红天桃服务"); ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("/beans/**/*.xml"); applicationContext.start(); while(true){ Thread.sleep(1000l); } }
读取项目路径下文件。报错URI is not hierarchical
InputStream resourceAsStream=null; String str =""; try{ resourceAsStream = this.getClass().getResourceAsStream(url);//this.getClass().getResource(str)达成jar后无法获取文件信息故更改方法 byte[] bytes = new byte[0]; bytes = new byte[resourceAsStream.available()]; resourceAsStream.read(bytes); str = new String(bytes); }catch(Exception e){ logger.error(e.getMessage()); }finally { try{ if(resourceAsStream!=null){ resourceAsStream.close(); } }catch(Exception e){ logger.error(e.getMessage()); } }
计算机科学领域的任何问题都可以通过增加一个间接的中间层来解决