boot

08_springboot2.x自定义starter

风格不统一 提交于 2019-12-15 01:07:41
概述 starter:启动器 1、这个场景需要使用到的依赖是什么? 2、如何编写自动配置 规则: @Configuration //指定这个类是一个配置类 @ConditionalOnXXX //在指定条件成立的情况下自动配置类生效 @AutoConfigureAfter //指定自动配置类的顺序 @Bean //给容器中添加组件 @ConfigurationPropertie结合相关xxxProperties类来绑定相关的配置 @EnableConfigurationProperties //让xxxProperties生效加入到容器中 自动配置类要能加载 将需要启动就加载的自动配置类,配置在META‐INF/spring.factories org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ org.springframework.boot.autoconfigure.admin.SpringApplicationAdminJmxAutoConfiguration,\ org.springframework.boot.autoconfigure.aop.AopAutoConfiguration,\ 模式: 启动器只用来做依赖导入; 专门来写一个自动配置模块; 启动器依赖自动配置;别人只需要引入启动器

Spring Boot 为什么这么火!

前提是你 提交于 2019-12-14 15:38:52
没错 Spring Boot 越来越火了,而且火的超过了我的预期,作为一名行走一线的 Java 程序员,你可能在各个方面感受到了 Spring Boot 的火。 Spring Boot 的火火火火火火 技术社区 Spring Boot 的文章越来越多;Spring Boot 相关的图文、视频课程越来越多;使用 Spring Boot 的互联网公司越来越多;现在出去面试 Java 工程师, Spring Boot 已经成了必问的内容。 一切都在证明,Spring Boot 已经成为了 Java 程序员必备的技能。并且可以预见的是未来 Spring Boot 的发展还会更好。 那我个人是如何感受到这一点呢? 三年前写的一个 Spring Boot 入门的文章,单篇文章阅读量超过百万!在百度指数上搜索 Spring Boot 关键字,可以看到一个气势如虹的增长曲线。 2016年,在 Github 上写了一个 Spring Boot 的开源项目,现在竟有 15000+ Star,6600 + Fork ,在 Github 上 Star 排名今次于 Spring Boot 官方。 项目名称:spring-boot-examples 项目地址: https://github.com/ityouknow/spring-boot-examples 注:这个开源项目还有很多国际友人参与贡献。

美团 Java 面试 154 道题分享

和自甴很熟 提交于 2019-12-14 13:39:32
Java集合22题 ArrayList 和 Vector 的区别。 说说 ArrayList,Vector, LinkedList 的存储性能和特性。 快速失败 (fail-fast) 和安全失败 (fail-safe) 的区别是什么? hashmap 的数据结构。 HashMap 的工作原理是什么? Hashmap 什么时候进行扩容呢? List、Map、Set 三个接口,存取元素时,各有什么特点? Set 里的元素是不能重复的,那么用什么方法来区分重复与否呢? 是用 == 还是 equals()? 它们有何区别? 两个对象值相同 (x.equals(y) == true),但却可有不同的 hash code,这句话对不对? heap 和 stack 有什么区别。 Java 集合类框架的基本接口有哪些? HashSet 和 TreeSet 有什么区别? HashSet 的底层实现是什么? LinkedHashMap 的实现原理? 为什么集合类没有实现 Cloneable 和 Serializable 接口? 什么是迭代器 (Iterator)? Iterator 和 ListIterator 的区别是什么? 数组 (Array) 和列表 (ArrayList) 有什么区别?什么时候应该使用 Array 而不是 ArrayList? Java 集合类框架的最佳实践有哪些? Set

精尽 Spring Boot 源码分析 —— 自动配置

二次信任 提交于 2019-12-14 11:29:40
精尽 Spring Boot 源码分析 —— 自动配置 1. 概述 本文,我们来分享 Spring Boot 自动配置的实现源码。在故事的开始,我们先来说两个事情: 自动配置和自动装配的区别? Spring Boot 配置的原理 2. 自动配置 V.S 自动装配 在这篇文章的开始,艿艿是有点混淆自动配置和自动装配的概念,后来经过 Google 之后,发现两者是截然不如同的: 自动配置:是 Spring Boot 提供的,实现通过 jar 包的依赖,能够自动配置应用程序。例如说:我们引入 spring-boot-starter-web 之后,就自动引入了 Spring MVC 相关的 jar 包,从而自动配置 Spring MVC 。 自动装配:是 Spring 提供的 IoC 注入方式,具体看看 《Spring 教程 —— Beans 自动装配》 文档。 所以,不要和艿艿一样愚蠢的搞错落。 3. 自动装配原理 胖友可以直接看 《详解 Spring Boot 自动配置机制》 文章的 「二、Spring Boot 自动配置」 小节,艿艿觉得写的挺清晰的。 下面,我们即开始正式撸具体的代码实现了。 4. @SpringBootApplication org.springframework.boot.autoconfigure.@SpringBootApplication 注解,基本我们的

关于spring boot上手的一点介绍

跟風遠走 提交于 2019-12-14 09:31:41
在spring官网网址 https://spring.io/guides 下,有许多相关介绍,包括可以构建的例子程序。 使用intellij idea,可以通过新建 spring boot initializr 项目,选择组件,搭建spring boot项目。 或者通过 https://start.spring.io/ 构建,效果和上边应该是一样,但没试过。intellij idea方式按介绍,也是通过这个调用来实现的。 另外看介绍,vscode也可以调用 spring boot initializr 搭建spring boot项目,没有试过。有评论说vscode对spring boot支持不是很好。 使用过spring的web,mybatis,devtools,tomcat组件;以及shiro。 来源: https://www.cnblogs.com/silvestris/p/12038058.html

SpringBoot2

本小妞迷上赌 提交于 2019-12-14 09:31:22
一、thymeleaf模板   1、在pom.xml中导入依赖 <!-- 添加thymeleaf模版的依赖 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>   2、配置application.yml文件 ###配置thymeleaf spring: thymeleaf: cache: false   3、在resources目录下添加templates包,并在此包下创建index.html页面 <!DOCTYPE html> <html lang="en" xmlns:th="http://www.w3.org/1999/xhtml"> <head> <meta charset="UTF-8"> <title>thymeleaf模板页面</title> </head> <body> <ul th:each="stu:${stuList}"

Android Start App On Boot from BroadcastReceiver Crashing

坚强是说给别人听的谎言 提交于 2019-12-14 03:59:24
问题 I am trying to start my Android 2.1 Galaxy S Phone on boot and it crashes. Here is my receiver if I comment out context.startActivity(i) I don't get crash otherwise I see it on powerup. startActivity from another activity using same ACTION does not cause crash. This seems to be just on Boot. public class MyBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Intent i = new Intent(); i.setAction("DISPLAY_FIRSTPAGE"); context

Working across sub-lists with apply() functions

﹥>﹥吖頭↗ 提交于 2019-12-14 03:22:48
问题 I am trying to the bootstrap the proportional occurrence of diet items for 7 individuals and calculate a sd() Lets say there are 9 prey items on the menu. Diet <- c("Beaver","Bird", "Bobcat","Coyote", "Deer", "Elk", "Porcupine", "Raccoon", "SmMamm") And that these prey items are eaten by 7 different individuals of the same species Inds <- c("P01", "P02", "P03", "P04", "P05", "P06", "P07") My goal is the bootstrap the proportional occurrence of each diet item for each individual. The loop

Start Android Service on boot time Android 4.0

蹲街弑〆低调 提交于 2019-12-14 03:00:44
问题 I'm triying to start a android service in android 4.0 when the device is booting, in boot time, but it's imposible , I had be used many codes, copy and paste. I had used code from here, stackoverflow of others examples and questions , but for me is imposible. I'm using android 4.0.1 in a table Acer Iconia A501. I put my code here. Somebody Can it try this code??? this is the page :This page please, it is easy 回答1: You need to register a broadcast receiver for the intent that is broadcast on

精尽 Spring Boot 源码分析 —— Condition

只谈情不闲聊 提交于 2019-12-13 12:48:39
精尽 Spring Boot 源码分析 —— Condition 1. 概述 在前面的文章,我们已经看过 Spring Boot 如何实现 自动配置 的功能,但是,实际场景下,这显然不够。为什么呢?因为每个框架的 配置 ,需要满足一定的 条件 ,才应该进行 自动配置 。这时候,我们很自然就可以想到 Spring Boot 的 Condition 功能。不过呢,Condition 功能并不是 Spring Boot 所独有,而是在 Spring Framework 中就已经提供了。那么,究竟是什么样的关系呢,我们在 「2. Condition 演进史」 来瞅瞅。 2. Condition 演进史 2.1 Profile 的出场 在 Spring3.1 的版本,为了满足不同环境注册不同的 Bean ,引入了 @Profile 注解。例如: @Configuration public class DataSourceConfiguration { @Bean @Profile("DEV") public DataSource devDataSource() { // ... 单机 MySQL } @Bean @Profile("PROD") public DataSource prodDataSource() { // ... 集群 MySQL } } 在测试环境下,我们注册单机