随笔分类 -  spring

摘要:@Configuration @ConditionalOnExpression("${conditional.configuration.switch:true}") public class TaskScheduled { @Scheduled(cron = "15,30,45 * * * * ? 阅读全文
posted @ 2024-06-29 21:35 Bonnie_ξ 阅读(4) 评论(0) 推荐(0) 编辑
摘要:一.读取springboot 自带的application.properties或application.yml文件 1.通过@Value注解来读取 application.properties文件内容: name=1 user.name=2 读取方式: @Value("${name}") priv 阅读全文
posted @ 2022-08-11 22:57 Bonnie_ξ 阅读(371) 评论(0) 推荐(0) 编辑
摘要:SpringBoot创建定时任务,目前主要有以下三种实现方式: 一、基于注解(@Scheduled) 基于注解@Scheduled默认为单线程,开启多个任务时,任务的执行时机会受上一个任务执行时间的影响; 二、基于接口(SchedulingConfigurer) 用于实现从数据库获取指定时间来动态执 阅读全文
posted @ 2022-08-11 22:43 Bonnie_ξ 阅读(8033) 评论(0) 推荐(0) 编辑
摘要:目前开发的SpringBoot项目在启动的时候需要预加载一些资源。而如何实现启动过程中执行代码,或启动成功后执行,是有很多种方式可以选择,我们可以在static代码块中实现,也可以在构造方法里实现,也可以使用@PostConstruct注解实现。 当然也可以去实现Spring的Application 阅读全文
posted @ 2022-05-07 10:37 Bonnie_ξ 阅读(68) 评论(0) 推荐(0) 编辑
摘要:对象、数组、集合 ObjectUtils 获取对象的基本信息 // 获取对象的类名。参数为 null 时,返回字符串:"null" String nullSafeClassName(Object obj) // 参数为 null 时,返回 0 int nullSafeHashCode(Object 阅读全文
posted @ 2022-02-28 15:47 Bonnie_ξ 阅读(27) 评论(0) 推荐(0) 编辑
摘要:一、前言 在日常开发中,经常会遇到需要在配置文件中,存储 List 或是 Map 这种类型的数据。 Spring 原生是支持这种数据类型的,以配置 List 类型为例,对于 .yml 文件配置如下: test: list: - aaa - bbb - ccc 对于 .properties 文件配置如 阅读全文
posted @ 2021-09-16 09:30 Bonnie_ξ 阅读(144) 评论(0) 推荐(0) 编辑
摘要:项目描述 笔记博客系统 springboot开发自动建表的博客系统包含前后端 markdown编辑 运行环境 jdk8+mysql+IntelliJ IDEA+maven 项目技术(必填) spring+springboot+mybatis+layui+jquery 数据库文件 链接:https:/ 阅读全文
posted @ 2021-08-29 18:38 Bonnie_ξ 阅读(92) 评论(0) 推荐(0) 编辑
摘要:@PropertySource注解是Spring用于加载配置文件,默认支持.properties与.xml两种配置文件。@PropertySource属性如下: name:默认为空,不指定Spring自动生成 value:配置文件 ignoreResourceNotFound:没有找到配置文件是否忽 阅读全文
posted @ 2021-08-29 18:27 Bonnie_ξ 阅读(286) 评论(0) 推荐(0) 编辑
摘要:@ConfigurationProperties使用 @ConfigurationProperties( prefix = "hello.properties" ) public class MyProperties { private String myKey; private List<Stri 阅读全文
posted @ 2021-08-29 18:25 Bonnie_ξ 阅读(100) 评论(0) 推荐(0) 编辑
摘要:1、监听容器刷新完成扩展点ApplicationListener<ContextRefreshedEvent> ApplicationContext事件机制是观察者设计模式实现的,通过ApplicationEvent和ApplicationListener这两个接口实现ApplicationCont 阅读全文
posted @ 2021-08-29 18:21 Bonnie_ξ 阅读(67) 评论(0) 推荐(0) 编辑
摘要:@RequestMapping注解的源码 @Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @Documented @Mapping public @interface Reques 阅读全文
posted @ 2021-08-29 18:10 Bonnie_ξ 阅读(55) 评论(0) 推荐(0) 编辑
摘要:一、前言 项目配置完之后,接着就是写接口了,那咱们就开始吧。 二、项目配置补充知识点 上篇文章写的是关于项目属性配置的一些知识,这里针对上次遗忘内容进行补充如下: 2.1、获取配置文件的值 在application.yml 文件中,示例内容如下: server: port: 8888 name: x 阅读全文
posted @ 2021-08-29 18:07 Bonnie_ξ 阅读(90) 评论(0) 推荐(0) 编辑
摘要:一、前言 写代码就和恋爱一样,有反馈就要趁热打铁,搞完了项目搭建,接下来就来搞搞项目配置。 二、IDEA设置 1、编码配置 这里所说的就是代码的编码格式,你可以不设置,但是可能要面临的是,很多未知的麻烦,比如乱码是很坑的呀(真的谁遇见,谁知道,恶心的一批)。 单击 File -> Settings, 阅读全文
posted @ 2021-08-29 18:05 Bonnie_ξ 阅读(34) 评论(0) 推荐(0) 编辑
摘要:https://www.cnblogs.com/longronglang/p/15152849.html 写在前面 现在已经是八月份了,我已经荒废了半年居多,不得不说谈恋爱确实是个麻烦的事,谈好了皆大欢喜,分手了就是萎靡不振,需要很长一段时间才能缓过来。 人还是要有梦想的,至于实现只不过是一个契机, 阅读全文
posted @ 2021-08-29 18:02 Bonnie_ξ 阅读(50) 评论(0) 推荐(0) 编辑
摘要:前言 AnnotationConfigApplicationContext或者AnnotationConfigWebApplicationContext 进行扫描。用于构建bean定义以及初始化Spring容器。 它是在spring3.0版本之后出现的。此注解是spring支持注解驱动开发的一个标志 阅读全文
posted @ 2021-08-19 10:29 Bonnie_ξ 阅读(46) 评论(0) 推荐(0) 编辑
摘要:1、配置Maven依赖 Spring Boot自动化配置主要依赖如下两个包: spring-boot-starter:打包starter主要依赖 configuration-processor:自动化配置主要依赖 <dependency> <groupId>org.springframework.b 阅读全文
posted @ 2021-08-19 10:28 Bonnie_ξ 阅读(47) 评论(0) 推荐(0) 编辑
摘要:目录 Spring注解开发 bean注册到Spring容器中 applicationContext.xml添加包扫描注解 实体类添加注解@Component 属性注入 属性添加注解@Value("张三丰") @Component的衍生注解 dao层 @Repository service层 @Ser 阅读全文
posted @ 2021-08-19 10:21 Bonnie_ξ 阅读(27) 评论(0) 推荐(0) 编辑
摘要:1、两者的联系和区别 @Component 和 @Bean 是两种使用注解来定义bean的方式。 @Component(和@Service和@Repository)用于自动检测和使用类路径扫描自动配置bean。注释类和bean之间存在隐式的一对一映射(即每个类一个bean)。 这种方法对需要进行逻辑 阅读全文
posted @ 2021-08-14 23:15 Bonnie_ξ 阅读(168) 评论(0) 推荐(0) 编辑
摘要:Spring Boot 实现Swagger 2 Spring Boot 集成 Swagger 2很简单,首先新建一个 SpringBoot 项目,这里就不重新创建项目,直接使用之前的rest 测试项目。然后引入依赖并做基础配置即可: 1、配置Swagger2的依赖 在pom.xml 配置文件中,增加 阅读全文
posted @ 2021-08-13 16:43 Bonnie_ξ 阅读(93) 评论(0) 推荐(0) 编辑
摘要:背景 软件开发过程中,不可避免的是需要处理各种异常,就我自己来说,至少有一半以上的时间都是在处理各种异常情况,所以代码中就会出现大量的try {...} catch {...} finally {...} 代码块,不仅有大量的冗余代码,而且还影响代码的可读性。比较下面两张图,看看您现在编写的代码属于 阅读全文
posted @ 2021-08-12 13:50 Bonnie_ξ 阅读(67) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示