自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

程序员备忘录

工作与学习的点点滴滴...

  • 博客(85)
  • 收藏
  • 关注

原创 码农常用/好用工具【持续更新】

1. Online UMLhttps://www.draw.io/2. Maven repositoryhttps://mvnrepository.com/3. PDF Drive is your search engine for PDF fileshttps://www.pdfdrive.net/4. Android测试版计划https://www.google.com/a...

2018-05-15 11:11:27 2090 2

原创 Mybatis One-to-many mapping

We can map one-to-many types of results to a collection of objects using the <collection> element.The JavaBeans for Course and Tutor are as follows:public class Course{ private Integer cour...

2018-12-26 15:07:25 439

原创 Mybatis auto generated keys

1. Support AUTO_INCREMENT columnsWe can use the useGeneratedKeys and keyProperty attributes to let the database generate the auto_increment column value and set that generated value into one of the i...

2018-12-26 11:35:19 964

转载 Maven中dependencyManagement标签使用

一句话解释项目中多个模块间公共依赖的版本号、scope的控制业务场景一个项目有很多模块,每个模块都会用到一些公共的依赖.这些公共的依赖若交由各个模块独自管理,若每个模块同一个依赖的版本号不一致,会造成很比问题。打包和开发测试环境下对同一jar包不同版本号的处理可能不一致,造成运行时和测试时结果不一致项目升级时,会造成修改版本号时遍地开花的问题。该标签通常适用于多模块环境下定义一个to...

2018-12-24 14:48:39 1895

原创 Spring boot 异常处理之最佳实践

1. controller类内部异常处理器@RestController@RequestMapping("/exception")public class ExceptionController{ @Autowired private UserService userService; @RequestMapping("/test1") public v...

2018-12-24 13:43:06 435

原创 使用Spring Boot Actuator插件监控性能

Spring Boot Actuator的关键特性是在应用程序里提供众多Web端点,通过它们了解应用程序运行时的内部状况。有了Actuator,你可以知道Bean在Spring应用程序上下文里是如何组装在一起的,掌握应用程序可以获取的环境属性信息,获取运行时度量信息的快照。1. 简单使用1. Maven依赖<dependency> <groupId>o...

2018-12-22 17:50:04 1880

原创 Spring Boot 中使用@DateTimeFormat和@JsonFormat注解

被@DateTimeFormat和@JsonFormat注解修改的属性字段应该是Data类型@DateTimeFormat转换前端string类型到后端date类型,此字段一般加到属性上面@JsonFormat转换后端date类型到前端string类型,如果只用到此注解,加到属性上或者方法上都可以;如果跟@DateTimeFormat配合使用,此注解添加到getter方法上面,注意加【tim...

2018-12-13 11:41:23 18989

原创 Spring Boot 中基于注解和xml使用 dubbo

1. 基于注解1.1. provider 配置信息application.ymlspring: dubbo: server: true registry: zookeeper://127.0.0.1:2181 application: name: dubbo-providerserver: port: 8089pom.xml<d...

2018-12-12 14:46:28 602

原创 Spring Boot 属性注入的两种方式

属性注入的两种方式@Value & @ConfigurationPropertiesapplication.ymlspring:  profiles:    active: devapplication-dev.ymlbook:  name: test  price: 15.00  writer: garypublic class Book{    @V...

2018-12-10 19:03:43 858

转载 彻底解决mysql中文乱码【转载】

mysql是我们项目中非常常用的数据型数据库。但是因为我们需要在数据库保存中文字符,所以经常遇到数据库乱码情况。下面就来介绍一下如何彻底解决数据库中文乱码情况。1、中文乱码1.1、中文乱码 create table user(name varchar(11)); # 创建user表 insert into table user("carl"); # 添加数据...

2018-11-30 23:45:11 1604 1

转载 避坑必看:很详尽的MyBatis返回自增主键实验【转载】

避坑必看:很详尽的MyBatis返回自增主键实验(包括插入或更新SQL语句insert on duplicate key update的自增主键返回情况)目录1. 实验对比维度(1)单纯的insert和insert on duplicate key update(2)selectKey和useGeneratedKeys(3)@Param和parameterType(4)单个...

2018-11-30 23:36:50 1156 3

原创 Maven中设置镜像仓库的简单配置

在maven的settings.xml 文件里配置mirrors的子节点,添加如下mirror:<mirror><id>nexus-aliyun</id><mirrorOf>*</mirrorOf><name>Nexus aliyun</name><url>http://m

2018-11-30 23:27:58 316

原创 java中{0}占位符的使用

MessageFormat.format(“一种简单的Java占位符实现:{0}分隔{1}”, "val1" ,”val2”)); 

2018-11-30 23:24:23 9061

原创 生成六位随即验证码的一种简单实现

public static String generateRandomNum(){ Random random = new Random(); String result=""; for (int i=0;i<6;i++) { result+=random.nextInt(10); } return result;} 

2018-11-30 23:19:40 1010

原创 SpringBoot 实现定时任务

串行调度与并行调度1. 串行调度使用的注解: @Scheduled 和 @EnableScheduling@SpringBootApplication@EnableSchedulingpublic class ScheduleApplication{ public static void main(String[] args) { SpringA...

2018-11-30 23:09:15 143

原创 Mac Pro 卸载与安装 JDK 以及 设置 JAVA_HOME & PATH

查看 JAVA VERSION输入:ls /Library/Java/JavaVirtualMachines/输出:jdk1.8.0_191.jdk 查看 $JAVA_HOME /usr/libexec/java_home -v 1.8 Mac Pro 卸载 JDKsudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletP...

2018-11-24 13:19:29 866

原创 将 Http 请求返回的 json 格式数据转换为 Object

本文只贴出核心部分代码,与业务相关的代码没有放出来~自己觉得 Spring boot 中这么实现不是最优的,贴出来待后期优化,也望有更优解的不吝赐教~​ public List<PoliceAccount> getInfoFromRemote() { List<PoliceAccount> accounts= new ArrayLi...

2018-11-12 15:19:30 3625

原创 intellij idea 导入多个 maven 工程[可用]

intellij idea 导入多个 maven 工程1. 新建文件夹 Test2. 在 Test 文件夹下新建/拷入多个工程3. 通过菜单 File->Open... 打开 Test 文件夹4. 点击右侧栏的 Maven Projects 按钮,通过点击 “+” 按钮,添加每个项目中的 pom.xml 文件...

2018-11-02 00:01:36 569

原创 CentOS offline 安装 MySQL8.0.12

CentOS offline 安装 MySQL8.0.121. 官网下载二进制安装包2. 解压文件:#tar -xJvf mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz -C /usr/local/# mv /usr/local/mysql-8.0.12-linux-glibc2.12-x86_64/ /usr/local/mysql3. 配置参数文...

2018-10-31 20:58:40 209

原创 MySQL语句批量执行

mysql>source batch.sql文件 batch.sql 包含以下内容:source 001.sqlsource 002.sqlsource 003.sqlsource 004.sqlsource 005.sqlsource 006.sqlsource 007.sqlsource 008.sqlsource 009.sql

2018-10-30 16:45:34 1837

原创 MySQL建表语句导出

public static void exports() { Connection con = null; Statement stmt = null; PreparedStatement pstmt = null; try { Class.forName("com.mysql.jd...

2018-10-30 14:55:17 909

原创 Linux环境下面安装apache-tomcat-9.0.12

Linux环境下面安装apache-tomcat-9.0.121. 新建安装目录   cd /usr/local/   mkdir tomcat9   cd tomcat92. 下载并解压安装包   从网上下载apache-tomcat-9.0.12.tar.gz   解压到tomcat93. 将启动脚本/bin/catalina.sh复制到init.d下   cp -p /us...

2018-10-29 11:18:36 1615

转载 第一次有人把“分布式事务”讲的这么简单明

事务的具体定义事务提供一种机制将一个活动涉及的所有操作纳入到一个不可分割的执行单元,组成事务的所有操作只有在所有操作均能正常执行的情况下方能提交,只要其中任一操作执行失败,都将导致整个事务的回滚。简单地说,事务提供一种“要么什么都不做,要么做全套(All or Nothing)”机制。数据库本地事务ACID说到数据库事务就不得不说,数据库事务中的四大特性 ACID:A:原子...

2018-10-26 14:03:48 216

转载 分布式事务,原来可以这么玩

多个数据要同时操作,如何保证数据的完整性,以及一致性?答 : 事务 ,是常见的做法。举个栗子:用户下了一个订单,需要修改 余额表 , 订单 表 , 流水 表 ,于是会有类似的伪代码:start transaction;CURD table t_account; any Exception rollback;CURD table t_order; any Excepti...

2018-10-26 13:39:37 114

转载 拜托,面试别再问我基数排序了!!!

排序,面试中考察基本功问的比较多,工作多年以后,对排序的细节记忆不那么清楚的小伙伴,面试时会比较吃亏。 有一种很神奇的排序,基数排序(Radix Sort),时间复杂度为O(n),今天花1分钟,通过几幅图,争取让大家搞懂细节。 画外音:居然还有时间复杂度为O(n)的排序算法?不但有,其实还有很多。 举个栗子:假设待排序的数组arr={72, 11, 82, 32, 44,...

2018-10-26 12:46:05 798 1

转载 如何在10亿数中找出前1000大的数

小史是一个应届生,虽然学的是电子专业,但是自己业余时间看了很多互联网与编程方面的书,一心想进BAT互联网公司。简单的自我介绍后,面试官给了小史一个问题。  题目:如何在10亿数中找出前1000大的数? 小史:我可以用分治法,这有点类似快排中partition的操作。随机选一个数t,然后对整个数组进行partition,会得到两部分,前一部分的...

2018-10-26 12:29:43 336

转载 如何判断一个数是否在40亿个整数中

小史是一个应届生,虽然学的是电子专业,但是自己业余时间看了很多互联网与编程方面的书,一心想进BAT。今天他就去BAT中的一家面试了,简单的自我介绍后,面试官给了小史一个问题!题目:我有40亿个整数,再给一个新的整数,我需要判断新的整数是否在40亿个整数中,你会怎么做? 【请教大神】小史回到学校,把面试的情况和计算机学院的吕老师说了...

2018-10-26 12:19:34 440

原创 Spring Boot 整合 Mybatis

public class User{ private int id; private String name; private int age; public User(int id, String name, int age) { this.id = id; this.name = name; this...

2018-10-17 19:57:15 115

原创 根据经纬度查询具体地址

根据经纬度查询地址详细信息, Java 代码实现public static String getAdd(String lng, String lat) { String urlString = "http://api.map.baidu.com/geocoder/v2/?ak=pWNVQZQIhhhtdXhgxdBKtoMxhMFNhWPC&callback=...

2018-10-17 16:37:53 10187 1

转载 LaunchPad删除应用或残留图标的几种办法[转载]

以下几种方案基本上可以删除掉Mac launchPad中各种形式的应用1、按住option键(或长按图标)出现抖动,如图标左上角有删除标识,点击就可以删除,如没有删除标识,请参考下面办法2、Finder中找到Applications文件夹(默认左边快捷已提供),选中需要删除的应用,拖到垃圾桶,如没有找到需要删除的应用,请参考下面办法3、呼出Spotlight(ctrl+space),搜...

2018-09-14 11:49:14 4964 1

原创 How to install and config spark on Ubuntu/Linux

1. Download spark-2.3.1-bin-hadoop2.7.tgz from http://spark.apache.org/downloads.html2. unzip the file spark-2.3.1-bin-hadoop2.7.tgz3. Set the SPARK_HOME and PATHexport SPARK_HOME=/home/myname/sp...

2018-08-08 10:44:06 176

原创 How to install and config the Go on Ubuntu/Linux

1. Download go1.10.3.linux-amd64.tar.gz from https://golang.org/dl/2. unzip the file go1.10.3.linux-amd64.tar.gz3. Set the GOROOT and PATHexport GOROOT=/home/gary/goexport PATH=$PATH:$GOROOT/bin...

2018-07-29 18:00:55 140

原创 How to download and install git on Ubuntu/Linux

1) For the latest stable version for your release of Linux/Ubuntusudo apt-get install git2) For Ubuntu, this PPA provides the latest stable upstream Git versionsudo add-apt-repository ppa:git-core/ppa...

2018-07-05 22:53:19 259

原创 How to install and config jdk10 on Ubuntu/Linux

1) Download jdk-10.0.1_linux-x64_bin.tar.gz2) Unzip jdk-10.0.1_linux-x64_bin.tar.gz3) Set the JAVA_HOME, CLASSPATH and PATHsudo gedit /etc/profileexport JAVA_HOME=/usr/lib/Java/jdk-10.0.1export JRE_HO...

2018-07-05 22:29:59 159

原创 How to install and config maven on Ubuntu/Linux

1) Download apache-maven-3.5.4-bin.tar.gz2) Unzip apache-maven-3.5.4-bin.tar.gz3) Set the M2_HOME, CLASSPATH and PATHsudo gedit /etc/profileexport M2_HOME=/usr/lib/apache-maven-3.5.4export CLASSPATH=$...

2018-07-05 22:26:45 155

原创 How to use kafka2.12 as a MQ on the Ubuntu18.04/Linux

1. Download the kafka from the ApacheBinary downloads:  Scala 2.12  - kafka_2.12-1.1.0.tgz (asc, sha512)2. unzip the kafka_2.12-1.1.0.tgz3. Start the zookeeper   bin/zookeeper-server-start.sh config/z...

2018-06-30 10:59:25 198

原创 how to download and install hadoop on Windows10/Ubuntu18.04

1) Download the hadoop(1) open this link - http://hadoop.apache.org/releases.html(2) find and click "mirror site" Download the release hadoop-X.Y.Z-src.tar.gz from a mirror site.(3) We suggest the fol...

2018-06-21 15:07:36 161

原创 Ubuntu18.04 install Redis

Download, extract and compile Redis with:$tar xzf redis-4.0.9.tar.gz$cd redis-4.0.9$make$make test1)cc adlist.o /bin/sh:1:cc:not foundsudo apt-get install gcc 2)redis jemallo/jemallo.h:no such file or...

2018-06-13 00:25:11 1455

原创 Insert binary data into Oracle database

1. how to insert binary files into oracle databasegrant dba to demo identified by demo;CREATE DIRECTORY image_files AS '/Data/Files';GRANT READ ON DIRECTORY image_files TO demo;create table demo.image...

2018-05-31 14:33:02 212

转载 ubuntu18.04 安装 mysql8.0.11[亲测管用]

如果 你是 sudo apt install mysql-server那么 安装 过程中 不会 提示  输入密码  ,然后 你就 坑爹 了  。 可能的  解决 方案 sudo vim /etc/mysql/debian.cnf  update mysql.user set authentication_string=password('password') where user='root'an...

2018-05-12 11:59:22 2080 2

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除