摘要: 一、singleton和prototype public class Bean1 { public Bean1() { System.out.println(this.getClass().getSimpleName() + ":" + this.toString() + " has been cr 阅读全文
posted @ 2018-12-01 15:06 柚子苹果果 阅读(259) 评论(0) 推荐(0) 编辑
摘要: 一、实例化Bean 1. 通过默认构造方法实创建Bean public class Bean1 { public Bean1() { System.out.println(this.getClass().getSimpleName() + " has been created"); } } Bean 阅读全文
posted @ 2018-11-30 16:55 柚子苹果果 阅读(431) 评论(0) 推荐(0) 编辑
摘要: 一、场景模拟 public interface Human { public void goHome(); } Human:人类,下班了该回家啦 public interface Car { void start(); void stop(); void turnLeft(); void turnR 阅读全文
posted @ 2018-11-30 16:21 柚子苹果果 阅读(333) 评论(0) 推荐(0) 编辑
摘要: 在之前的文章里介绍了SpringBoot和SpringSecurity如何继承。之后我们需要考虑另外一个问题:当前微服务化也已经是大型网站的趋势,当我们的项目采用微服务化架构时,往往会出现如下情况: 首先,我们会建立一个用户中心UserCenter,实现用户的登录、登出以及其他用户信息维护等相关功能 阅读全文
posted @ 2018-11-19 15:39 柚子苹果果 阅读(5822) 评论(0) 推荐(0) 编辑
摘要: 当我们在项目中引入了SpringSecurity框架进行身份校验的时候,如果某个请求需要用户身份认证,那么SpringSecurity会将用户redirect到登录页面。但是有些时候我们希望是forward到登录页面而不是redirect到登录页面,这种情况下可做如下配置: 关键代码就是标红这部分, 阅读全文
posted @ 2018-11-15 15:52 柚子苹果果 阅读(815) 评论(0) 推荐(0) 编辑
摘要: 一、最简单认证服务器 1. pom依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <depe 阅读全文
posted @ 2018-11-08 17:54 柚子苹果果 阅读(17087) 评论(3) 推荐(4) 编辑
摘要: 一、基本环境搭建 父pom依赖 <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.3.RELEASE</versi 阅读全文
posted @ 2018-11-05 16:17 柚子苹果果 阅读(6211) 评论(0) 推荐(0) 编辑
摘要: 如果你需要在你的SpringBoot启动完成之后实现一些功能,那么可以通过创建class实现ApplicationRunner和CommandLineRunner来完成: 如果你定义了多个ApplicationRunner或者CommandLineRunner,并想要控制他们执行的先后顺序,可以让你 阅读全文
posted @ 2018-11-01 17:49 柚子苹果果 阅读(623) 评论(0) 推荐(0) 编辑
摘要: 如果你需要获取通过SpringApplication.run(…​)传输过来的arguments,可以直接注入一个ApplicationArguments即可实现,如下面这个例子: 当然,要注意的是SpringBoot的启动类中,在执行run方法的时候参数不能为空(标红部分): 阅读全文
posted @ 2018-11-01 17:35 柚子苹果果 阅读(4079) 评论(0) 推荐(0) 编辑
摘要: SpringBoot Application共支持6种事件监听,按顺序分别是: ApplicationStartingEvent:在Spring最开始启动的时候触发 ApplicationEnvironmentPreparedEvent:在Spring已经准备好上下文但是上下文尚未创建的时候触发 A 阅读全文
posted @ 2018-11-01 15:09 柚子苹果果 阅读(2390) 评论(0) 推荐(0) 编辑