SpringBoot中常用注解1. Bean处理1.1 依赖注入1.1.1 @Autowired1.2 标注类被Spring容器管理1.2.1 @Component1.2.2 @Respository1.2.3 @Service1.2.4 @Controller1.2.5 @RestController1.2.6 @Configuration1.2.7 @Scope2. HTTP请求2.1 @G
转载 2023-09-24 18:59:10
99阅读
最近通过做一些小项目来复习 SpringBoot 的相关知识,在这里顺便把 SpringBoot 中的注解做下记录,方便后续复习。 文章目录一、@SpringBootApplication二、@Component、@Service、@Controller、@Repository三、@ResponseBody四、@RestController五、@AutoWired、@Qualifier、@Reso
转载 2024-02-04 07:34:55
64阅读
# SpringBoot配置MySQL注解版 ## 概述 在开发Java应用程序时,我们经常需要使用数据库来存储和管理数据。MySQL是一个流行的关系型数据库系统,而SpringBoot是一个用于快速开发应用程序的框架。本文将介绍如何使用SpringBoot配置MySQL数据库,并通过注解的方式操作数据。 ## 准备工作 首先,我们需要创建一个SpringBoot项目。可以使用[Spring
原创 2023-08-16 16:37:42
71阅读
# 在Spring Boot中实现MySQL悲观锁注解 ## 一、引言 在高并发的应用场景下,数据库的并发处理能确保数据的一致性和完整性。我们可以通过使用MySQL的悲观锁来实现这点。在Spring Boot中,这通常通过注解来实现。本文将指导你如何在Spring Boot下使用MySQL悲观锁。 ## 二、流程概述 在我们进行悲观锁实现之前,可以通过以下流程步骤进行操作: | 步骤 |
原创 9月前
68阅读
目录 @Autowired @Component: @Controller: @Service: @Repository: @Override @Service() DAO层 @Bean @Bean @Configuration @Autowired @A...
转载 2020-03-12 15:31:00
684阅读
2评论
这将 java 类标记为 bean。它是任何 Spring 管理组件的通用构造型。sprin...
原创 2021-09-28 15:26:11
932阅读
基于注解@Scheduled默认为单线程,开启多个任务时,任务的执行时机会受上一个任务执行时间的影响。@Component @Configuration //1.主要用于标记配置类,兼备Component的效果。 @EnableScheduling // 2.开启定时任务 public class SaticScheduleTask { //3.添加定时任务 @Scheduled(cro
转载 2024-03-20 13:51:52
42阅读
 一、注解(annotations)列表1、@SpringBootApplication包含了@ComponentScan、@Configuration和@EnableAutoConfiguration注解。其中@ComponentScan让Spring Boot扫描到Configuration类并把它加入到程序上下文。2、@ComponentScan组件扫描,可自动发现和装配一些Bea
转载 2024-05-16 13:17:00
29阅读
一、注解(annotations)列表@SpringBootApplication: 包含了@ComponentScan、@Configuration和@EnableAutoConfiguration注解。 其中@ComponentScan让spring Boot扫描到Configuration类并把它加入到程序上下文。 home.php?mod=space&uid=1414569 等同于
一、注解(annotations)列表 @SpringBootApplication:包含了@ComponentScan、@Configuration和@EnableAutoConfiguration注解。其中@ComponentScan让Spring Boot扫描到Configuration类并把它加入到程序上下文。@Configuration 等同于spring的XML配置文件;使用java代
配置类相关:@PropertySource(value = "classpath:test.properties")   //我们都把配置文件写到application.yml中。有时我们不愿意把配置都写到application配置文件中,这时需要我们自定义配置文件,比如test.properties:@ConfigurationProperties(prefix =
转载 2024-05-28 15:00:40
55阅读
1.SpringBoot/spring @SpringBootApplication: 包含@Configuration、@EnableAutoConfiguration、@ComponentScan通常用在主类上;@Repository: 用于标注数据访问组件,即DAO组件;@Service: 用于标注业务层组件; @MappedSuperClass: 用在确定是父类的entity上。
转载 2024-06-28 10:45:13
58阅读
1. @TARGET * 用于标注这个注解放在什么地方,类上,方法上,构造器上 * ElementType.METHOD 用于描述方法 * ElementType.FIELD 用于描述成员变量,对象,属性(包括enum实例) * ElementType.LOCAL_VARIABLE 用于描述局部变量 ...
转载 2021-07-16 17:03:00
97阅读
2评论
# class位于类路径上,才会实例化一个Bean@ConditionalOnClass# 在当前上下文中存在某个对象时,才会实例化一个Bean@ConditionalOnBean# 当表达式为true的时候,才会实例化一个Bean@ConditionalOnExpression# 仅仅在当前上下文中不存在某个对象时,才会实例化一个Bean@ConditionalOn...
原创 2022-02-18 13:39:44
118阅读
@RestController 只是用于接口 默认返回数据格式为json,位置用在类上面。@Controller +
原创 2023-04-23 13:00:34
81阅读
首先,先看SpringBoot的主配置类:@SpringBootApplication public class StartEurekaApplication { public static void main(String[] args) { SpringApplication.run(StartEurekaApplication.class, args);
转载 2024-03-19 14:44:23
16阅读
一、启动注解 @SpringBootApplication@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented @Inherited @SpringBootConfiguration @EnableAutoConfiguration @ComponentScan(excludeFilters = { @F
场景公司有一个业务需要控制db0和db1的两个数据源的表的事务,每次都要自己多个开启,比较麻烦,因为公司是自定义框架所以模拟springjdbc的DataSourceTransactionManager多数据源控制 和@Transactional注解模拟写了一个多数据源管理事务的注解@LdTransactional解决方案查看DataSourceTransactionManager源码得知,实际是
注解(annotations)列表@SpringBootApplication:包含了@ComponentScan、@Configuration和@EnableAutoConfiguration注解。其中@ComponentScan让spring Boot扫描到Configuration类并把它加入到程序上下文。@Configuration 等同于spring的XML配置文件;使用Jav
转载 2024-06-25 19:59:06
124阅读
@SpringBootApplication,替代@SpringBootConfiguration、@EnableAutoConfiguration、@ComponentScan @ImportAutoConfiguration,导入配置类,一般做测试的时候用,正常优先使用@EnableAutoConfiguration @SpringBootConfiguration,替代@Configurat
  • 1
  • 2
  • 3
  • 4
  • 5