Spring Data JPA
发表于|更新于|SpringSpring Data JPA
|总字数:34|阅读时长:1分钟|浏览量:
简介
- Spring Data JPA 是在 JPA 规范的基础下提供了 Repository 层的实现
- 底层基于 hibernate
参考
文章作者: 王文哲
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 王文哲的博客!
相关推荐
2023-11-12
Spring-注册Bean
静态注册@Bean、@Component、@Service 等@Import12@Import(DatabaseConfig.class)@Import({Student.class, Teacher.class}) 动态注册自动注册@ImportSelector 实现 ImportSelector 接口的方法 selectImports 返回要注入类的名称的数组 1 手动注册ImportBeanDefinitionRegistrar 实现 ImportBeanDefinitionRegistrar 接口的方法 registerBeanDefinitions。支持自定义Bean 的名称 DefaultListableBeanFactory - registerSingleton12345678ApplicationContext applicationContext = SpringContextUtils.getApplicationContext(); DefaultListableBeanFactory beanFactory =...
2023-09-15
Spring-redis-key过期监听
说明 监听 redis key 过期失效。只能监听到 key 值 ,获取不到 value 值 删除 key 时,不会监听到该事件 代码123456789101112131415161718192021222324@Component@Slf4jpublic class RedisKeyExpiredListener extends KeyExpirationEventMessageListener { // 通过构造函数注入 RedisMessageListenerContainer 给 KeyExpirationEventMessageListener public RedisKeyExpiredListener(RedisMessageListenerContainer listenerContainer) { super(listenerContainer); } @Override protected void doHandleMessage(Message message) { ...
2023-05-10
Spring-注解
@DateTimeFormat说明@DateTimeFormat 是 Spring 框架提供的注解,它的主要作用是将前端传入的日期时间字符串按照指定的格式进行格式化,转换成 Java 中的 java.util.Date 或 java.time.LocalDateTime 类型。在前后端分离的架构中,通常需要使用这个注解来处理前端传入的日期时间数据。在使用该注解时,需要注意指定日期时间字符串的格式,以便正确地解析成对应的日期时间对象 示例 实体类成员变量添加注释 12@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")private Date taskLimitTime; @JsonFormat@JsonFormat 是 Jackson 序列化库提供的注解,它的作用是定义 Json 对象在序列化成字符串时的格式。该注解可以应用于序列化的字段、getter 和 setter 方法、构造函数参数等。 在使用 @JsonFormat 时,可以通过一系列属性来设置 Json...
2022-09-07
Spring-Event
来源:blog.csdn.net/csp732171109/article/details/124377254 写在最前实际业务开发过程中,业务逻辑可能非常复杂,核心业务 + N个子业务。如果都放到一块儿去做,代码可能会很长,耦合度不断攀升,维护起来也麻烦,甚至头疼。还有一些业务场景不需要在一次请求中同步完成,比如邮件发送、短信发送等。 MQ 确实可以解决这个问题,但 MQ 重啊,非必要不提升架构复杂度。针对这些问题,我们了解一下 Spring Event ApplicationEvent - 一般Spring Event(Application Event)其实就是一个观察者设计模式,一个 Bean 处理完成任务后希望通知其它 Bean 或者说一个 Bean 想观察监听另一个Bean 的行为。 Spring Event 用来解耦业务真的贼好用! Demo 地址:https://gitee.com/csps/mingyue-springboot-learning 1.自定义事件定义事件,继承 ApplicationEvent...
2021-01-29
Spring Cache
Spring Cachehttps://www.cnblogs.com/fashflying/p/6908028.html Cache 存储方式CacheManager 是 Spring 定义的一个用来管理 Cache 的接口。Spring 自身已经为我们提供了两种 CacheManager 的实现,一种是基于 Java API 的 ConcurrentMap,另一种是基于Ehcache的 Cache 实现。如果我们需要使用其它类型的缓存时,我们可以自己来实现 Spring 的 CacheManager 接口或 AbstractCacheManager 抽象类。下面分别来看看 Spring 已经为我们实现好了的两种 CacheManager 的配置示例 基于 Java API 的 ConcurrentMap12345678<bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager"> <property...
2020-12-04
Spring-AOP
学习https://www.yiibai.com/spring_aop/springaop_around_aspect.html https://www.cnblogs.com/leeSmall/p/7667040.html https://mrbird.cc/深入理解Spring-AOP原理.html 说明实现 AOP 关键特点是定义好两个角色 切点 和 切面 execution切点函数语法:execution(方法修饰符(可选) 返回类型 方法名 参数 异常模式(可选)) 参数部分允许使用通配符: 12345* 匹配任意字符,但只能匹配一个元素.. 匹配任意字符,可以匹配任意多个元素,表示类时,必须和*联合使用+ 必须跟在类名后面,如Horseman+,表示类本身和继承或扩展指定类的所有类 1234567891011121314151617//表示匹配所有方法 1)execution(* *(..)) //表示匹配com.fsx.run.UserService中所有的公有方法 2)execution(public *...