- 博客(16)
- 收藏
- 关注
原创 java8中lambda的用法(map转list,list转map)
注意List 使用前需要做非空处理1.以某个属性分组Map<String,List<User>> map= userList.stream().collect(Collectors.groupingBy(User::getName));2.获取集合中的某个属性转为集合pictureList.stream().map(Picture::getSrc).collect(Collectors.toList());3.根据集合中的某个属性进行升序重排roomList.stre
2021-01-22 13:41:42
1532
原创 mysql将多个字段(列)合并成一个字段(一列)
一:sql语句SELECT declare_type_id,support_model,project_name,CONCAT(declare_type_id,support_model,project_name) from gf_index;二:结果
2021-01-20 14:28:29
2170
1
原创 private static final Logger logger=xxx 之为什么用static和final??
private static final Logger logger= LoggerFactory.getLogger(ShiroConfig.class);我们经常这样创建日志实例,那么为什么要用static还有final呢??1.定义成static final,logger变量不可变,读取速度快2.static 修饰的变量是不管创建了new了多少个实例,也只创建一次,节省空间,如果每次都创建Logger的话比较浪费内存;final修饰表示不可更改,常量3.将域定义为static,每个类中只有一
2021-01-14 10:22:25
718
原创 java编程中@SuppressWarnings(“unused“)这个注解是什么意思?
java编程中@SuppressWarnings(“unused”)这个注解是什么意思?@SuppressWarnings(“unused”) 表示该属性在方法或类中没有使用。添加此注解可以去除属性上的黄色警告!!!
2021-01-14 10:16:56
162
原创 Linux关闭防火墙并设置开机启动/不启动
本文针对Centos6和7对于Centos6:查看防火墙:[root@CactiEZ ~]# service iptables status关闭防火墙:[root@CactiEZ ~]# service iptables stop开启防火墙:[root@CactiEZ ~]# service iptables start永久关闭防火墙:查询开启iptables是否启动[root@CactiEZ ~]# chkconfig --list | grep iptablesiptable
2020-08-19 15:01:52
2826
原创 代码优化
尽量重用对象,不要循环创建对象,比如for循环拼接字符串;容器初始化若能提前预知长度则指明长度;遍历map时候使用Entry遍历Mapfor(Map.Entry<String,String> entry : map.entrySet){ String key=entry.getKey(); String value=entry.getValue();}尽量使用基本类型而不是包装类型;尽量减小同步作用范围 synchronize方法 VS synchronize代码块;尽量使用
2020-07-02 20:24:36
97
原创 GC调优
GC调优步骤打印GC日志根据日志得到关键性能指标分析GC原因,调优JVM参数ParallelGC调优关注点:吞吐量、最大停顿时间、最小停顿时间、平均停顿时间、YGC发生次数、FullGC发生次数。设置Metaspace大小-XX:MetaspaceSize=64M-XX:MaxMetaspaceSize=64M添加吞吐量和停顿时间参数-XX:GCTimeRatio=99 -XX:MaxGCPauseMillis=100G1调优关注点:吞吐量、最大停顿时间、最小停顿时间、平均停顿时间、
2020-07-02 20:22:49
135
原创 Can not issue data manipulation statements with executeQuery()
错误信息:java.sql.SQLException: Can not issue data manipulation statements with executeQuery(). at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:996) at com.mysql.jdbc.SQLError.createSQLExcept...
2020-02-08 16:24:08
317
原创 org.apache.ibatis.exceptions.PersistenceException:
错误信息:org.apache.ibatis.exceptions.PersistenceException:### Error querying database. Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException...
2020-02-08 16:12:49
457
原创 Property 'ID_CARD_NO' not found on type com.amg.entity.Item
javax.el.PropertyNotFoundException: Property ‘ID_CARD_NO’ not found on type com.amg.entity.Item解决方案:sql select 查询语句返回ID_CARD_NO字段,结果在com.amg.entity.Item类中找不到相应的属性...
2020-02-08 16:04:35
226
原创 Statement returned more than one row, where no more than one was expected
executor.ExecutorException: Statement returned more than one row, where no more than one was expected解决方案:想要的结果是要一个对象,但是查出来的结果是一个List ,那么就超出了 resultType 设置的参数,修改返回值类型即可。...
2020-02-08 16:02:38
3475
原创 Mapped Statements collection does not contain value for
Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for原因:不能匹配。解决方案:配置文件中的id 方法名和dao 接口中的方法名一致。...
2020-02-08 16:00:26
190
原创 SpringJUnit4ClassRunner requires JUnit 4.12 or higher.
java.lang.IllegalStateException: SpringJUnit4ClassRunner requires JUnit 4.12 or higher.解决方案:原因:版本的型号的问题,只兼容 junit 4.12 版本,切换版本即可。
2020-02-08 15:58:08
1700
原创 Failed to load ApplicationContext
java.lang.IllegalStateException: Failed to load ApplicationContext解决方案:通常是因为applicationContent.xml里面的bean初始化失败的原因。或者少导入了一个jar 包
2020-02-08 15:56:05
179
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人