首页 > 其他分享 >SpringBoot官方笔记7IO

SpringBoot官方笔记7IO

时间:2023-07-17 22:56:43浏览次数:38  
标签:SpringBoot 7IO spring org cache 笔记 springframework mail import

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

标签:SpringBoot,7IO,spring,org,cache,笔记,springframework,mail,import
From: https://www.cnblogs.com/df888/p/17561527.html

相关文章

  • SpringBoot官方笔记6消息
    TheSpringFrameworkprovidesextensivesupportforintegratingwithmessagingsystems,fromsimplifieduseoftheJMSAPIusing JmsTemplate toacompleteinfrastructuretoreceivemessagesasynchronously.SpringAMQPprovidesasimilarfeaturesetforth......
  • SpringBoot官方笔记5Data
    SpringBootintegrateswithanumberofdatatechnologies,bothSQLandNoSQL.SQLDatabasesSpringData providesanadditionalleveloffunctionality:creating Repository implementationsdirectlyfrominterfacesandusingconventionstogeneratequeries......
  • SpringBoot官方笔记8其他
    ContainerImagesFROMeclipse-temurin:17-jreasbuilderWORKDIRapplicationARGJAR_FILE=target/*.jarCOPY${JAR_FILE}application.jarRUNjava-Djarmode=layertools-jarapplication.jarextractFROMeclipse-temurin:17-jreWORKDIRapplicationCOPY--from=......
  • 决策单调性优化DP 学习笔记 & P4767 [IOI2000] 邮局 题解
    0.题面题目描述高速公路旁边有一些村庄。高速公路表示为整数轴,每个村庄的位置用单个整数坐标标识。没有两个在同样地方的村庄。两个位置之间的距离是其整数坐标差的绝对值。邮局将建在一些,但不一定是所有的村庄中。为了建立邮局,应选择他们建造的位置,使每个村庄与其最近的邮局......
  • 组合数学学习笔记
    组合数学学习笔记组合数学常用公式基本公式排列:\[A_{n}^r=\frac{n!}{(n-r)!}\]组合:\[C_{n}^r=\frac{n!}{r!(n-r)!}\\\dbinom{n}{r}=\frac{n!}{r!(n-r)!}\]组合公式杨辉恒等式......
  • 第一篇博客 练习typora笔记
    学习MarkDown字体helloworld!helloworld!helloworld!helloworld! 引用 乐交诤友不交损友 分割线 图片  超链接点击跳转到百度 列表ABC 无序列表ABC 列表姓名性別年齡張三男18 代碼publicvoid......
  • springboot下使用rabbitMQ之开发配置方式(一)
    springboot下使用rabbitMQ之开发配置方式(一)距离上次发布博客已经小一年了,这次...嗯,没错,我又回来啦.........
  • C++笔记(2)——函数
    六.函数6.1函数基础一个典型的函数(function)定义包括:返回类型(returntype)、函数名字,由0或多个形参(parameter)组成的列表以及函数体。我们通过调用运算符来执行函数,形式为"()"。函数调用完成两项工作:一是用实参初始化函数对应的形参,二是将控制权转移给被调用函数。此时,主调......
  • mysql 笔记
    行转列: namecoursegradezhangsanjava20zhangsanc#60zhangsanpython40lisijava109lisic#30lisipython20wangwujava33 selectname,sum(casewhencourse='java'thengradeend)as'java',sum(casewhen......
  • 小红书获得小红书笔记详情 API 返回值说明
    ​ item_get_video-获得小红书笔记详情 注册开通smallredbook.item_get_video公共参数名称类型必须描述keyString是调用key(必须以GET方式拼接在URL中)secretString是调用密钥api_nameString是API接口名称(包括在请求地址中)[item_search,item_get,item_s......