- 博客(30)
- 资源 (3)
- 收藏
- 关注
原创 springboot注入第三方jar包的类
比如我们要注入CrawlerTask1,CrawlerTask2这个两个类因为这两个类没有被@Service,@Repository等类注解,如果我们想用@Autowired注入会报错@Autowiredprivate CrawerTask1 crawerTask1;我们可以新建一个Config类,在里面获得我们想要注入的第三方jar包的类,通过@Configuration注解这...
2019-05-05 13:57:50
12730
4
原创 MySQL事务整理
事务?事务是访问数据库的一个操作序列,数据库应用系统通过事务集来完成对数据库的存取。事务的正确执行使得数据库从一种状态转换为另一种状态时对应的数据结果的正确性。事务必须服从ACID原则,原子性、一致性、隔离性、持久性。1.原子性一个事务是一个不可分割的最小单位,一个事务中的操作要么都成功提交,要么都失败回滚,不可以只执行事务中的某部分的操作。2.一致性一致性确保了数据的完整...
2019-04-23 17:32:09
184
原创 日志常用配置
建一个名为logback-spring.xml的xml文件<?xml version="1.0" encoding="utf-8" ?><configuration> <!--控制台输出日志配置--> <appender name="consoleLog" class="ch.qos.logback.core.Con
2019-01-07 10:46:29
231
原创 BeanUtils.copyProperties 属性复制List的坑
BeanUtils.copyProperties 大家都知道是用来作为属性复制的工具,最近在项目遇到了一个坑class A{ private String name; private List<Cat> cats; private String age;}class Cat{ private String color; private ...
2018-11-15 21:34:42
26676
7
原创 通过Java反射处理对象的属性
我这边工作中有个需求要求String类型的字段入库是去掉空格,我想到了两种方式处理1.第一种是在实体类中的set方法中处理,这种方法我就不说了2.第二种是通过反射处理对象的属性,废话不多说放上代码public static Object stringTrim(Object model) { if(model==null){ return mod...
2018-11-06 20:36:11
760
原创 Java中BigDecimal使用注意事项
public static void main(String[] args) { System.out.println("a="+new BigDecimal(1.3)); System.out.println("b="+new BigDecimal("1.3")); }输出:a=1.300000000000000044408920985006...
2018-10-09 14:33:33
317
转载 Eclipse注释模板设置
转自:https://blog.youkuaiyun.com/paul342/article/details/52982585<?xml version="1.0" encoding="UTF-8"?><templates> <template autoinsert="false" contex...
2018-07-18 09:46:32
319
原创 线程的异常处理
run()方法中不允许抛出checked exception,可以抛出unchecked exception。什么是unchecked 和 checked 异常所有的checked exception异常必须在run()方法中处理。
2018-07-08 22:54:45
363
原创 属性复制
package org.apache.commons.beanutils BeanUtils.copyProperties(A,B);B中和A有相同属性名称的值复制给A
2018-07-05 16:39:22
654
原创 springmvc拦截器
创建一个类LoginInterceptor 实现HandlerInterceptor 接口public class LoginInterceptor implements HandlerInterceptor { @Value("${TT_TOKEN}") private String TT_TOKEN; @Value("${SSO_LOGIN_URL}") ...
2018-06-10 16:57:22
224
原创 nginx反向代理,负载均衡
upstream tomcatserver1 { server 192.168.72.49; }upstream tomcatserver2 { server 192.168.72.50; }server{ listen 80; server_name www.test1.com; location /{ proxy_p...
2018-06-09 18:34:52
158
原创 nginx 配置静态文件
server { listen 80; //监听端口号 server_name localhost;// 域名 location / { //表示拦截:server_name/ip+listen root html;//指定html文件夹为根目录(一般为: nginx/html),是相对目录 index ...
2018-06-09 17:37:18
2325
转载 redis bind 设置
在 Linux 中安装了redis 服务在 Windows 中安装了xampp环境。以供PHP运行PHP代码如下:?123456<code class="language-php hljs "><!--?php $redis = new Redis(); $redis--->connect('192.168.1.4', 6379); $redis->...
2018-06-08 16:21:03
1193
转载 centos7 redis集群搭建
试验机操作系统:CentOS Linux release 7.2.1511 (Core)本文的目的是教会大家快速搭建redis集群,完了再深入学习。试问如果不上手试验,看的资料再多有个毛用?下载redis下载网址:https://redis.io/download写文章时最新版本为:redis-4.0.1.tar.gz可以先下载到windows操作系统,然后拷贝到centos。下载成功后,在cen...
2018-06-08 15:07:21
855
转载 nginx图片服务器搭建
一、安装Nginx先安装Nginx,看我之前发的文章: 搭建Nginx服务器二、安装vsftpd再安装vsftpd组件,看我之前发的文章: Linux安装ftp组件(8步完成)三、开始搭建Nginx图片服务器1、效果例如:图片通过ftp服务上传到/home/ftpuser/www/images目录下,我想通过访问Nginx服务器来访问ftp目录下的图片文件,该url为http://192.168....
2018-06-08 14:24:45
320
转载 centos7 安装JDK
卸载查看已经安装的jdk[root@bogon jre]# rpm -qa|grep jdkjava-1.8.0-openjdk-headless-1.8.0.65-3.b17.el7.x86_64java-1.7.0-openjdk-1.7.0.91-2.6.2.3.el7.x86_64java-1.7.0-openjdk-headless-1.7.0.91-2.6.2.3.el7.x86...
2018-06-08 11:49:38
151
转载 springmvc全局异常处理
需求:在SpringMVC中实现全局异常捕获解析以及处理并且返回json状态码需求分析解决:1、进入Spring-MVC配置文件配置全局异常处理 <!-- 全局异常处理 自定义实现spring的全局异常解析器HandlerExceptionResolver --> <bean id="exceptionResolver" class="com.xxx.resolv...
2018-06-06 23:18:49
294
转载 redis4伪集群搭建
redis4集群三台服务器:先设置hosts10.0.0.231 node110.0.0.232 node210.0.0.233 node3端口分配:node1:7000 node1:7001 node2:7002 node2:7003 node3:7004 node3:70051:下载redis-4.0.1并解压解压目录:/usr/local/redis-4.0....
2018-06-05 10:35:17
335
原创 FtpClient工具类
package com.hjj.util;import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPReply; import java.io.*; /** * JAVA FTPClient 工具类 * * commons-net-1.4.1.jar PFTClinet...
2018-06-03 20:02:58
1064
原创 spring父子容器
<!-- 初始化spring容器 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext-*.xml</param-value> </context-par...
2018-06-02 09:45:51
50157
转载 linux关闭防火墙开放接口等常用命令
CentOS6.5查看防火墙的状态:1[linuxidc@localhost ~]$service iptable status 显示结果:12345[linuxidc@localhost ~]$service iptable statusRedirecting to /bin/systemctl status iptable.service● iptable.service Loaded...
2018-05-31 11:53:04
873
原创 mybatis中的limit参数
参数page=1,rows=3错误写法:select * from xxx limit #{page},#{rows}报错:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use ne...
2018-04-16 09:24:33
22839
9
原创 mybatis like模糊查询问题
1. 参数中直接加入%% param.setUsername("%CD%"); param.setPassword("%11%"); <select id="selectPersons" resultType="person" parameterType="person"> select id,sex,age,username,password from per
2018-02-28 16:52:57
194
转载 mybatis if判断语句的问题
最近在项目使用mybatis中碰到个问题 Xml代码 <if test="type=='y'"> and status = 0 </if> 当传入的type的值为y的时候,if判断内的sql也不会执行,抱着这个疑问就去看了mybatis是怎么解析sql的。下面我们一起来看一下mybatis 的执行过程。 DefaultSqlSession.class 1...
2018-02-28 16:51:24
413
原创 Could not find result map Java.util.Map 问题分析
主要是大部分人写成了<select id="XXX"resultMap="java.util.Map" >正确写法<select id="XXX"resultType="java.util.Map" >
2018-01-16 09:55:21
2313
2
原创 mysql将一张表中的某些数据更新到另一张表中
update table1,table2 set table1.column=table1.column where 额外条件
2017-12-22 13:40:52
2125
原创 mysql where和having区别
where筛选作用于group by 前 having 筛选作用于 group by 之后看个例子:select student_id,sum(student_grade) from student_table group by student_id having sum(student_grade) >500查询总分大于500分的学生的id和学科总分这里用where不能筛选
2017-12-22 13:11:55
272
原创 javabean转化为json格式的过滤 值为空或为null时的字段
我们向前端传数据时大多数都是先从从数据库中查询出来注入到实体类中然后转化为json格式再传给前端,如果数据库没有实体类对应的字段或者数据库中的值为null,则对应的实体类的属性为null。此时我们传给前端的结果会是这样,null值的字段都为空有时我们需要过滤掉这些空值的字段,我们使用这段代码JsonConfig jsonConfig = new JsonConfig();
2017-12-20 17:15:21
9720
从Paxos到Zookeeper 分布式一致性原理与实践----
2019-04-02
java深入理解jvm第二版
2019-04-01
深入理解Nginx模块开发与架构解析第2版
2018-07-07
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人