SpringBoot简介
https://spring.io/guides
http://www.spring4all.com/article/246
http://www.spring4all.com/article/558
http://www.ityouknow.com/spring-boot.html
Spring 官方网站本身使用Spring 框架开发,随着功能以及业务逻辑的日益复杂,应用伴随着大量的XML配置文件以及复杂的Bean依赖关系。
随着Spring 3.0的发布,Spring IO团队主键开始摆脱XML配置文件,并且在开发过程中大量使用“约定优先配置”(convention over configuration)的思想来摆脱Spring框架中各种复杂的配置,衍生了Java Config。
Spring Boot正是在这样的一个背景下被抽象出来的开发框架,它本身并不提供Spring框架的核心特性以及扩展功能,只是用于快速、敏捷地开发新一代基于Spring框架的应用程序。也就是说,它并不是用来替代Spring的解决方案,而是和Spring框架紧密结合用于提升Spring开发者体验的工具。同时它集成了大量常用的第三方库配置(例如Jackson, JDBC, Mongo, Redis, Mail等等),Spring Boot应用中这些第三方库几乎可以零配置的开箱即用(out-of-the-box),大部分的Spring Boot应用都只需要非常少量的配置代码,开发者能够更加专注于业务逻辑。
该项目旨在帮助开发者更容易地创建基于Spring的应用程序和服务,使得现有的和新的Spring开发者能够最快速地获得所需要的Spring功能。
Spring Boot不生成代码,且完全不需要XML配置。其主要目标如下:
- 为所有的Spring开发工作提供一个更快、更广泛的入门经验。
- 开箱即用,你也可以通过修改默认值来快速满足你的项目的需求。
- 提供了一系列大型项目中常见的非功能性特性,如嵌入式服务器、安全、指标,健康检测、外部配置等。
下面我们创建一个 HelloController.java 定义3个方法
package org.springboot.sample.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/hello")
public class HelloController {
@RequestMapping
public String hello() {
return "Hello Spring-Boot";
}
@RequestMapping("/info")
public Map
Map
map.put("name", name);
return map;
}
@RequestMapping("/list")
public List
List
Map
for (int i = 1; i <= 5; i++) {
map = new HashMap<>();
map.put("name", "Shanhy-" + i);
list.add(map);
}
return list;
}
}
然后现在可以直接运行
SpringBootSampleApplication 的main方法,和执行普通java程序一样。
然后可以看到spring-boot 内置server容器(默认为Tomcat),这一切spring-boot 都帮我们做好了。
控制台输出内容 Started
SpringBootSampleApplication in 7.358 seconds (JVM running for 9.154) 表示服务已经启动。
在浏览器输入我们3个请求便可看到结果。
http://localhost:8080/hello
输出:Hello Spring-Boot
http://localhost:8080/hello/info?name=shanhy
输出:{“name”:”shanhy”}
http://localhost:8080/hello/list
输出:[{“name”:”Shanhy-1”},{“name”:”Shanhy-2”},{“name”:”Shanhy-3”},{“name”:”Shanhy-4”},{“name”:”Shanhy-5”}]
通过我们的Hello实例,相信大家一目了然,可谓spring-boot创建一个项目如此简单,完全可以在几分钟内将服务启动。
spring-boot抛弃繁琐的配置,让开发人员更专注与业务逻辑的实现。后面几篇文章将会对spring-boot的多个方面通过实例的方式呈现给大家。
依赖库
https://github.com/alibaba/druid/tree/master/druid-spring-boot-starter
https://github.com/prometheus/prometheus
https://github.com/netdata/netdata
https://github.com/OpenFeign/feign
Spring Boot JDBC
https://www.yiibai.com/springjdbc/create_query.html
https://juejin.im/post/5aa38906f265da239147b95e
Spring Boot 配置使用 HTTPS
https://zhuanlan.zhihu.com/p/31385073
http://blog.wxcsdb88.com/2017/08/29/spring-boot-https/
https://zhuanlan.zhihu.com/p/32545108
springboot多环境配置(yml)
https://www.jianshu.com/p/3b1ba2158f5b
MyBatis教程
从两个钟变成2天,是什么原因导致?
第一天上午看如下教程:
https://www.cnblogs.com/ityouknow/p/6037431.html
https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-mybatis-annotation
实现该教程,然后看如下教程
https://www.yiibai.com/mybatis/install_configure.html
漏了一句话导致浪费时间:3个小时左右
下午4点半开始正式写代码,选择了下面的模型移植到fusionmind:
https://www.jianshu.com/p/5cd772c07041
https://blog.csdn.net/Winter_chen001/article/details/78622141
19点移植完,但是问题很多开始定位
22:55完成可以在dls数据库下发数据到数据库
各种配置问题
第二天上午添加delete接口,传入参数Integer的问题,上午11点问题解决,耗时3个小时
但是发现json下发post到数据库为NULL,这个问题到晚上8点解决,耗时8个小时
https://www.bysocket.com/?p=1627
添加注解方式的mybatis,发现空指针问题(
java.lang.NullPointerException),共花时间4小时
Mybatis多表联合查询的方法:
https://my.oschina.net/u/2278977/blog/866608
https://www.cnblogs.com/shengulong/p/8385966.html
https://blog.csdn.net/wfq784967698/article/details/78786001
数据库教程
MySql:
启动与关闭:
windows操作系统下
启动服务
???mysqldadmin start 或 net start mysql
关闭服务
mysqladmin -uroot shutdown
net stop mysql
Linux操作系统下
启动服务
service mysqld start
关闭服务
service mysqld stop
重启服务
service mysqld restart
mysql –u root -p
https://blog.csdn.net/ithomer/article/details/5131863
https://blog.csdn.net/HXChuangxiaochuan/article/details/79000881
https://blog.csdn.net/hopyGreat/article/details/80526993
PostgreSQL:
http://3ms.huawei.com/hi/group/2952325/thread_5756407.html?mapId=7131187
http://3ms.huawei.com/km/blogs/details/5661201
postgreSQL常用命令
https://www.jianshu.com/p/8515a02492f1
https://www.yiibai.com/html/postgresql/2013/080436.html
/usr/local/postgresql10.6/data
pg_ctl restart
Python连接mysql或postgres(sqlalchemy)
https://my.oschina.net/u/2245781/blog/665075
Linux安装Redis
https://blog.csdn.net/u011669700/article/details/79566713
https://www.jianshu.com/p/bc84b2b71c1c
Java Json相关
https://blog.csdn.net/xiazdong/article/details/7059573
JSONArray转list
https://blog.csdn.net/qq_36306340/article/details/78732203
public static void main(String[] args) {
JSONArray jsonArray=new JSONArray();
jsonArray.add("1");
jsonArray.add("2");
jsonArray.add("3");
jsonArray.add("4");
jsonArray.add("5");
jsonArray.add("6");
System.err.println(jsonArray);
//把json数据放入到list中
List list = new ArrayList<>();
for(Object jstr:jsonArray){
list.add(jstr);
}
System.out.println(list);
}
Java解析Json数据的两种方式
https://blog.csdn.net/chenfengdejuanlian/article/details/52190462
java——读取JSON文件
https://blog.csdn.net/ALemon_Y/article/details/71436194
Java解析JSON文件的方法
https://blog.csdn.net/mingtianhaiyouwo/article/details/51336381
java中使用json- JSONObject、JSONArray相互嵌套
https://blog.csdn.net/flyliuweisky547/article/details/19172133
java封装多层json
https://blog.csdn.net/pan12jian/article/details/25987505
java中string与json互相转化
https://blog.csdn.net/u011575570/article/details/47863337
java中json字符串移除指定属性
https://blog.csdn.net/DUDUfine/article/details/52218463
Java文件读取
在Java中加入路径
https://codeday.me/bug/20171122/98549.html
Java判断文件、文件夹是否存在
https://blog.csdn.net/itmyhome1990/article/details/51243997
反斜杠(\)则不然,它和紧跟着它的那个字符构成转义字符,如“\n”(表示换行)、“\””(表示字符‘”’)等,所以在字符串中要表示字符'\'要用“\\”来表示,例:如果你这样定义一个字符串String s = “name\sex”是错误的,要这样定义String s = “name\\sex”;
Java数据类型
Java|Map、List与Set的区别
https://www.jianshu.com/p/f7365230dcf2
Java中List和ArrayList的区别
https://blog.csdn.net/erlian1992/article/details/51298276
https://www.jianshu.com/p/a6a708350743
Java中遍历Map的各种方式
https://blog.csdn.net/da_caoyuan/article/details/79819221
https://www.jianshu.com/p/3d1fb84b2b63
http://www.trinea.cn/android/hashmap-loop-performance/
hashmap判断是否存在key时,使用get(key)==null判断还是containsKey?
https://blog.csdn.net/fofabu2/article/details/78964079
IoC
Ioc和java反射技术的关系?
Ioc和依赖注入的关系?
https://www.cnblogs.com/weiyinfu/p/6835301.html
https://blog.csdn.net/HEYUTAO007/article/details/5981555
反射
https://blog.csdn.net/gdutxiaoxu/article/details/68947735
https://juejin.im/post/598ea9116fb9a03c335a99a4
https://www.sczyh30.com/posts/Java/java-reflection-1/#%E4%B8%80%E3%80%81%E5%9B%9E%E9%A1%BE%EF%BC%9A%E4%BB%80%E4%B9%88%E6%98%AF%E5%8F%8D%E5%B0%84%EF%BC%9F
mysql 按指定id排序
https://blog.csdn.net/pengone/article/details/49816131
https://blog.csdn.net/ylforever/article/details/79191182
How to return the ID of the inserted object under Postgres?
http://mybatis-user.963551.n3.nabble.com/How-to-return-the-ID-of-the-inserted-object-under-Postgres-td1926959.html
Java 8 Stream
http://www.runoob.com/java/java8-streams.html
接口引用指向实现类的对象
经常见List> list= new ArrayList>
Map,?> map = new HashMap,?>
但是发现list只是ArrayList的接口不是它的父类 ,不是父类引用指向子类对象
如果是应该是AbstractLIst ablist= new ArraryList(); 或者直接写为ArrayList> list= new ArrayList>
为什么要用接口引用指向实现类的对象
这种写法其实Java多态的表现形式
多态的定义:指允许不同类的对象对同一消息做出响应。即同一消息可以根据发送对象的不同而采用多种不同的行为方式。(发送消息就是函数调用)
List list;是在栈区开辟一个空间放list引用,并没有创建对象所以不知道ArrayList还是LinkedList当你list= new ArrayList(); 就创建了ArrayList对象。并且把开始创建的list引用指向这个对象ArrayList和LinkedList都是List的实现类。
为什么一般都使用 List list = new ArrayList() ,而不用 ArrayList alist = new ArrayList()呢?
问题就在于List有多个实现类,如 LinkedList或者Vector等等,现在你用的是ArrayList,也许哪一天你需要换成其它的实现类呢?,这时你只要改变这一行就行了:List list = new LinkedList(); 其它使用了list地方的代码根本不需要改动。假设你开始用 ArrayList alist = new ArrayList(), 这下你有的改了,特别是如果你使用了 ArrayList特有的方法和属性。 ,如果没有特别需求的话,最好使用List list = new LinkedList(); ,便于程序代码的重构. 这就是面向接口编程的好处
注意事项
list只能使用ArrayList中已经实现了的List接口中的方法,ArrayList中那些自己的、没有在List接口定义的方法是不可以被访问到的
list.add()其实是List接口的方法
但是调用ArrayList的方法如 clone()方法是调用不到的
接口的灵活性就在于“规定一个类必须做什么,而不管你如何做”。我们可以定义一个接口类型的引用变量来引用实现接口的类的实例,当这个引用调用方法时,它会根据实际引用的类的实例来判断具体调用哪个方法,这和上述的超类对象引用访问子类对象的机制相似。
//定义接口InterA
interface InterA
{
void fun();
}
//实现接口InterA的类B
class B implements InterA
{
public void fun()
{
System.out.println(“This is B”);
}
}
//实现接口InterA的类C
class C implements InterA
{
public void fun()
{
System.out.println(“This is C”);
}
}
class Test
{
public static void main(String[] args)
{
InterA a;
a= new B();
a.fun();
a = new C();
a.fun();
}
}
输出结果为:
This is B
This is C
上例中类B和类C是实现接口InterA的两个类,分别实现了接口的方法fun(),通过将类B和类C的实例赋给接口引用a,实现了方法在运行时的动态绑定,充分利用了“一个接口,多个方法”,展示了Java的动态多态性。
需要注意的一点是:Java在利用接口变量调用其实现类的对象的方法时,该方法必须已经在接口中被声明,而且在接口的实现类中该实现方法的类型和参数必须与接口中所定义的精确匹配。
Java设计模式代理模式
https://blog.csdn.net/carson_ho/article/details/54910472
线程池
Java里面线程池的顶级接口是Executor,但是严格意义上讲Executor并不是一个线程池,而只是一个执行线程的工具。真正的线程池接口是ExecutorService。下面这张图完整描述了线程池的类体系结构。
研究Java类加载机制
https://zyjustin9.iteye.com/blog/2092131
https://blog.csdn.net/lkforce/article/details/80253426
http://xiamianyu.github.io/2017/06/28/Java-%E5%90%AF%E5%8A%A8%E5%8F%82%E6%95%B0/
java命令行添加外部文件到classpath,从而实现读取外部配置文件
https://blog.csdn.net/gx304419380/article/details/80265720
https://www.cnblogs.com/xiaoqi/p/6955288.html
Linux jar包 后台运行 并生成log文件
https://blog.csdn.net/u012613251/article/details/80331994
Spring日志
https://code.skyheng.com/post/34603.html
https://www.cnblogs.com/keeya/p/10101547.html
https://www.jianshu.com/p/46b530446d20
https://blog.51cto.com/11931236/2058708
SpringBoot可执行包结构
https://blog.csdn.net/west_609/article/details/74906495
https://www.cnblogs.com/lmk-sym/p/6554382.html
证书:
https://www.cnblogs.com/littleatp/p/5922362.html
https://blog.csdn.net/liuchunming033/article/details/48470575
去包
https://www.cnblogs.com/yang-wu/p/3262499.html
https://ningyu1.github.io/site/post/93-maven-depenpency-analyze/
https://blog.csdn.net/qq_27093465/article/details/69226949
java定时任务
https://zhuanlan.zhihu.com/p/40785962
https://yq.aliyun.com/articles/2368
https://juejin.im/post/5b31b9eff265da598826c200
https://segmentfault.com/a/1190000013077817
Spring之RequestBody的使用姿势小结
https://juejin.im/post/5b5efff0e51d45198469acea
https://blog.csdn.net/qq_32423845/article/details/81199854
https://blog.csdn.net/qq_27603235/article/details/51604584
http://www.voidcn.com/article/p-kbigwhhu-bey.html