自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(16)
  • 收藏
  • 关注

原创 Redis注解默认序列化机制

Redis注解默认序列化机制打开Spring Boot整合Redis组件提供的缓存自动配置类RedisCacheConfiguration(org.springframework.boot.autoconfigure.cache包下的),查看该类的源码信息,其核心代码如下@Configurationclass RedisCacheConfiguration { @Bean public RedisCacheManager cacheManager(RedisConnectionFact

2020-06-09 14:03:01 308

原创 自定义RedisCacheManager

自定义RedisCacheManager​ 在项目的Redis配置类RedisConfig中,按照上一步分析的定制方法自定义名为cacheManager的Bean组件@Beanpublic RedisCacheManager cacheManager(RedisConnectionFactory redisConnectionFactory) {// 分别创建String和JSON格式序列化对象,对缓存数据key和value进行转换RedisSerializer strSerializer = n

2020-06-09 14:00:56 368

原创 SpringApplication的初始化过程

SpringApplication的初始化过程主要包括4部分,具体说明如下。(1)this.webApplicationType = WebApplicationType.deduceFromClasspath()用于判断当前webApplicationType应用的类型。deduceFromClasspath()方法用于查看Classpath类路径下是否存在某个特征类,从而判断当前webApplicationType类型是SERVLET应用(Spring 5之前的传统MVC应用)还是REACTIVE应

2020-06-08 10:59:22 236

原创 SpringApplication实例的初始化创建

SpringApplication实例的初始化创建​ 查看SpringApplication实例对象初始化创建的源码信息,核心代码具体如下javapublic SpringApplication(ResourceLoader resourceLoader, Class… primarySources) {this.sources = new LinkedHashSet();this.bannerMode = Mode.CONSOLE;this.logStartupInfo = true;thi

2020-06-08 10:55:13 210

原创 自定义starter

自定义starter的命名规则SpringBoot提供的starter以`spring-boot-starter-xxx`的方式命名的。官方建议自定义的starter使用`xxx-spring-boot-starter`命名规则。以区分SpringBoot生态提供的starter整个过程分为两部分:- 自定义starter- 使用starter首先,先完成自定义starter(1)新建maven  jar工程,工程名为zdy-spring-boot-starter,导入依赖:xml

2020-06-05 14:34:34 118

原创 SpringBoot starter机制

SpringBoot starter机制​ SpringBoot由众多Starter组成(一系列的自动化配置的starter插件),SpringBoot之所以流行,也是因为starter。starter是SpringBoot非常重要的一部分,可以理解为一个可拔插式的插件,正是这些starter使得使用某个功能的开发者不需要关注各种依赖库的处理,不需要具体的配置信息,由Spring Boot自动通过classpath路径下的类发现需要的Bean,并织入相应的Bean。例如,你想使用Reids插件,那么可

2020-06-05 14:29:51 139 1

原创 springboot底层自动配置的步骤

springboot底层实现自动配置的步骤是:1. springboot应用启动;2. @SpringBootApplication起作用;3. @EnableAutoConfiguration;4. @AutoConfigurationPackage:这个组合注解主要是@Import(AutoConfigurationPackages.Registrar.class),它通过将Registrar类导入到容器中,而Registrar类作用是扫描主配置类同级目录以及子包,并将相应的组件导入到sprin

2020-06-05 14:27:09 1222

原创 项目初始化启动过程

项目初始化启动过程大致包括以下部分:- 第一步:获取并启动监听器this.getRunListeners(args)和listeners.starting()方法主要用于获取SpringApplication实例初始化过程中初始化的SpringApplicationRunListener监听器并运行。- 第二步:根据SpringApplicationRunListeners以及参数来准备环境this.prepareEnvironment(listeners, applicationArguments

2020-06-05 14:22:36 436

原创 编写多语言国际化配置文件

编写多语言国际化配置文件​ 在项目的类路径resources下创建名称为i18n的文件夹,并在该文件夹中根据需要编写对应的多语言国际化文件login.properties、login_zh_CN.properties和login_en_US.properties文件login.propertiespropertieslogin.tip=请登录login.username=用户名login.password=密码login.rememberme=记住我login.button=登录login

2020-06-05 14:18:00 496

原创 完成数据的页面展示

完成数据的页面展示1. 创建Spring Boot项目,引入Thymeleaf依赖​ 2. 编写配置文件​ 打开application.properties全局配置文件,在该文件中对Thymeleaf模板页面的数据缓存进行设置properties# thymeleaf页面缓存设置(默认为true),开发中方便调试应设置为false,上线稳定后应保持默认truespring.thymeleaf.cache=false使用“spring.thymeleaf.cache=false”将Thymel

2020-06-05 14:13:48 224

原创 编写Web访问层Controller文件

编写Web访问层Controller文件java@RestController@RequestMapping(“api”) //窄化请求路径public class ApiCommentController {@Autowiredprivate ApiCommentService commentService;@RequestMapping(value = “/findCommentById”)public Comment findCommentById(Integer id){Comme

2020-06-05 14:10:47 344

原创 自定义RedisCacheManager

自定义RedisCacheManager​ 在项目的Redis配置类RedisConfig中,按照上一步分析的定制方法自定义名为cacheManager的Bean组件java@Beanpublic RedisCacheManager cacheManager(RedisConnectionFactory redisConnectionFactory) {// 分别创建String和JSON格式序列化对象,对缓存数据key和value进行转换RedisSerializer strSerialize

2020-06-05 14:06:19 302

原创 Redis注解默认序列化机制

Redis注解默认序列化机制打开Spring Boot整合Redis组件提供的缓存自动配置类RedisCacheConfiguration(org.springframework.boot.autoconfigure.cache包下的),查看该类的源码信息,其核心代码如下java@Configurationclass RedisCacheConfiguration {@Beanpublic RedisCacheManager cacheManager(RedisConnectionFactory

2020-06-05 14:02:47 739

原创 Spring优缺点分析

1.2.1 spring优缺点分析优点:spring是Java企业版(Java Enterprise Edition,JEE,也称J2EE)的轻量级代替品。无需开发重量级的Enterprise JavaBean(EJB),Spring为企业级Java开发提供了一种相对简单的方法,通过依赖注入和面向切面编程,用简单 的Java对象(Plain Old Java Object,POJO)实现了EJB的功能缺点:虽然Spring的组件代码是轻量级的,但它的配置却是重量级的。一开始,Spring用XML配置

2020-06-05 10:39:21 663

原创 Spring Boot 案例详解

1.3 SpringBoot 案例实现案例需求:请求Controller中的方法,并将返回值响应到页面(1)使用Spring Initializr方式构建Spring Boot项目​ 本质上说,Spring Initializr是一个Web应用,它提供了一个基本的项目结构,能够帮助我们快速构建一个基础的Spring Boot项目​ Project SDK”用于设置创建项目使用的JDK版本,这里,使用之前初始化设置好的JDK版本即可;在“Choose Initializr Service URL(选择

2020-06-04 15:28:46 147

原创 Spring Boot 基础

Spring Boot 基础1.1 约定优于配置Build Anything with Spring Boot:Spring Boot is the starting point for building all Spring-based applications. Spring Boot is designed to get you up and running as quickly as possible, with minimal upfront configuration of Spring.

2020-06-04 15:20:58 96

空空如也

空空如也

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

TA关注的人

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