java开发日常工作笔记

一、查看sql内容

在项目中mybatis日志打印级别配置文件修改日志打印级别后仍然没有打印sql,但是另一半运维急需sql,通过断点在
com.ibatis.sqlmap.engine.mapping.statement.MappedStatement#executeQueryWithCallback
查看变量sqlString的值获得sql内容。

pageHelper查看sql
ExecutorUtil  SimpleExecutor

二、mysql查询写入效率过慢问题

项目数据库由oracle切换成mysql后,数百万级的查询效率过慢,于是在必要字段添加了索引,查询问题解决。
但是后续批量插入数据时,插入几万条数据要耗时很久,经过排查问题是索引导致批量插入很慢,于是删除索引。
后续查询的问题采用读写分离的方案解决

三、多行编辑

Notepad++多行编辑
1)按住 Alt 键,然后用鼠标进行选择 
2)按住 Alt + Shift 键,然后用箭头(键盘的上下左右箭头)进行选择

四、报错:No identifier specified for entity xxx

报错,错误原因在实体类上添加了@entity注解却没有定义主键 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.interceptor.TransactionInterceptor#0': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in URL [file:/D:/project/xxx/WEB-INF/classes/obsContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [file:/D:/project/xxx/WEB-INF/classes/obsContext.xml]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: No identifier specified for entity: com.xxx.entity.xxxEntity

五、多个服务器session不共享解决方案

一、使用redis缓存判断登录,存储登录信息
二、nginx代理配置iphash,单ip固定访问某个节点

六、日期时间存储到数据库丢失时分秒

经过排查是由于中间有人使用了java.util.date转java.sql.date造成时分秒消失,java.sql.date是日期仅有年月日

七、soapui添加附件后webservice接口一直没能获取到文件上传参数

研究后soapui文档后发现mimeData要指向附件的name属性

八、项目中redis报错:redis.clients.jedis.exceptions.JedisDataException: ERR Client sent AUTH, but no password is set
redis服务器没有设置密码,客户端删除password即可。

九、java中计算x的y次方

double result = Math.pow(x, y)

十、项目启动报错

BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [file:/D:/project/xxxWEB-INF/classes/obsContext.xml]: Invocation of init method failed; nested exception is java.lang.NullPointerException

数据源错误

猜你喜欢

转载自blog.csdn.net/noob9527/article/details/96474681
今日推荐