SpringBoot官方笔记7IO

这篇具有很好参考价值的文章主要介绍了SpringBoot官方笔记7IO。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

Caching

Spring Boot auto-configures the cache infrastructure as long as caching support is enabled by using the @EnableCaching annotation.

import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;

@Component
public class MyMathService {

    @Cacheable("piDecimals")
    public int computePiDecimal(int precision) {
        ...
    }

}

Before invoking computePiDecimal, the abstraction looks for an entry in the piDecimals cache that matches the i argument. If an entry is found, the content in the cache is immediately returned to the caller, and the method is not invoked. Otherwise, the method is invoked, and the cache is updated before returning the value.

Redis

If Redis is available and configured, a RedisCacheManager is auto-configured.

spring.cache.cache-names=cache1,cache2
spring.cache.redis.time-to-live=10m
import java.time.Duration;

import org.springframework.boot.autoconfigure.cache.RedisCacheManagerBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.cache.RedisCacheConfiguration;

@Configuration(proxyBeanMethods = false)
public class MyRedisCacheManagerConfiguration {

    @Bean
    public RedisCacheManagerBuilderCustomizer myRedisCacheManagerBuilderCustomizer() {
        return (builder) -> builder
                .withCacheConfiguration("cache1", RedisCacheConfiguration
                        .defaultCacheConfig().entryTtl(Duration.ofSeconds(10)))
                .withCacheConfiguration("cache2", RedisCacheConfiguration
                        .defaultCacheConfig().entryTtl(Duration.ofMinutes(1)));

    }

}

If you need to disable caching altogether in certain environments, force the cache type to none to use a no-op implementation, as shown in the following example:

spring.cache.type=none

Sending Email

The Spring Framework provides an abstraction for sending email by using the JavaMailSender interface, and Spring Boot provides auto-configuration for it as well as a starter module.

spring.mail.properties[mail.smtp.connectiontimeout]=5000
spring.mail.properties[mail.smtp.timeout]=3000
spring.mail.properties[mail.smtp.writetimeout]=5000

Web Services

spring.webservices.wsdl-locations=classpath:/wsdl

参考资料:

https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#io文章来源地址https://www.toymoban.com/news/detail-598925.html

到了这里,关于SpringBoot官方笔记7IO的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 【笔记】Spring Boot 历史官方文档学习(持续更新)

    Spring Boot 2014正式发布1.0版本,距今已经快10年了。看历史官方文档了解重点feature, 帮助自己建立知识网络。 与 Spring 5 官网历史文档学习 一样,尽量保证不误解文档作者的原意,不好翻译的会有原文摘录(包括一些专有名词),并辅以自己的理解。限于篇幅原因,只摘录工作

    2024年02月10日
    浏览(28)
  • Spring MVC官方文档学习笔记(二)之DispatcherServlet

    1.DispatcherServlet入门 (1) Spring MVC是以前端控制器模式(即围绕着一个中央的Servelt, DispatcherServlet)进行设计的,这个DispatcherServlet为请求的处理提供了一个共用的算法,即它都会将实际的请求处理工作委托给那些可配置的组件进行执行,说白了,DispatcherServlet的作用就是进行统一调度,并

    2024年02月07日
    浏览(71)
  • Spring AOP官方文档学习笔记(二)之基于注解的Spring AOP

    1.@Aspect注解 (1) @Aspect注解用于声明一个切面类,我们可在该类中来自定义切面,早在Spring之前,AspectJ框架中就已经存在了这么一个注解,而Spring为了提供统一的注解风格,因此采用了和AspectJ框架相同的注解方式,这便是@Aspect注解的由来,换句话说,在Spring想做AOP框架之前,

    2023年04月17日
    浏览(32)
  • Spring MVC官方文档学习笔记(一)之Web入门

    注: 该章节主要为原创内容,为后续的Spring MVC内容做一个先行铺垫 1.Servlet的构建使用 (1) 选择Maven - webapp来构建一个web应用 (2) 构建好后,打开pom.xml文件,一要注意打包方式为war包,二导入servlet依赖,如下 (3) 替换webapp/WEB-INF/web.xml文件为如下内容,采用Servlet 3.1版本 (4) 在

    2024年02月03日
    浏览(32)
  • Spring AOP官方文档学习笔记(三)之基于xml的Spring AOP

    1.声明schema,导入命名空间 (1)如果我们想要使用基于xml的spring aop,那么,第一步,我们需要在xml配置文件中声明spring aop schema,导入命名空间,如下这是一个标准的模板 (2)在xml配置文件中,所有的切面以及通知等都必须放置于aop:config标签内 2.声明一个切面 3.声明一个切

    2024年02月02日
    浏览(31)
  • Spring AOP官方文档学习笔记(四)之Spring AOP的其他知识点

    1.选择哪种AOP (1) 使用Spring AOP比使用完整版的AspectJ更方便简单,因为不需要在开发和构建过程中引入AspectJ编译器以及织入器,如果我们只希望通知能够在Spring Bean上执行,那么选用Spring AOP就可以了,如果我们希望通知能够在不由Spring所管理的对象上执行,那么就需要使用AspectJ,如果

    2024年02月03日
    浏览(30)
  • 【springboot】Spring 官方抛弃了 Java 8!新idea如何创建java8项目

    我本来以为是 IDEA 版本更新导致的 Bug,开始还没在意。 直到我今天自己初始化项目时才发现:卧槽,Java 8 真没了?! 具体一点,应该是使用 IDEA 内置的 Spring Initializr 创建 Spring Boot 新项目时,没有 Java 8 的选项了,只剩下了 = 17 的版本 去网上搜了一圈,原来这是因为 Sprin

    2024年02月04日
    浏览(34)
  • Spring Initializr 构建 SpringBoot项目时Server URL选择start.spring.io和start.aliyun.com的区别

    提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 构建SpringBoot项目时默认的URL一直是start.spring.io,我也从未思考过这个网址有什么意义,直到今天新建SpringBoot项目时发现JAVA版本只有17和20,上网一查发现是因为 Spring Boot 官方不再支持 Spring Boot 的 2.x 版

    2024年02月03日
    浏览(40)
  • Spring学习笔记+SpringMvc+SpringBoot学习笔记

    1.1 概念 1、 POJO 是 Plain Old Java Object(简单老式Java对象)的缩写。它是指在Java开发中普通的Java对象,不依赖于特定的框架或技术。POJO 类型通常用于表示领域模型、数据传输对象(DTO)或实体对象等。 1.2 注解 1.1 SpringMVC概述 SpringMVC用于表现层开发,与Servlet相似,但使用上比

    2024年02月12日
    浏览(31)
  • Google IO 2023推出Android Studio官方AI工具Studio Bot

    在2023 Google I/O大会上,Google 宣布在 Android Studio 中推出了一款名为 Studio Bot 的新 AI 功能,它将为开发者提供更高效、智能的开发体验。Studio Bot 是一个基于机器学习的助手,可以帮助开发者处理重复性的任务,提高开发效率。 其中,Studio Bot 最为强大的功能之一是它能够自动

    2024年02月05日
    浏览(30)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包