肝了一周总结的SpringBoot常用注解大全,一目了然~

news2024/9/20 5:39:35

平时使用SpringBoot开发项目,少不了要使用到它的注解。这些注解让我们摆脱了繁琐的传统Spring XML配置,让我们开发项目更加高效,今天我们就来聊聊SpringBoot中常用的注解!

SpringBoot实战电商项目mall(50k+star)地址:https://github.com/macrozheng/mall

常用注解概览

这里整理了一张SpringBoot常用注解的思维导图,本文主要讲解这些注解的用法。

组件相关注解

@Controller

用于修饰MVC中controller层的组件,SpringBoot中的组件扫描功能会识别到该注解,并为修饰的类实例化对象,通常与@RequestMapping联用,当SpringMVC获取到请求时会转发到指定路径的方法进行处理。

/**
 * @auther macrozheng
 * @description 后台用户管理Controller
 * @date 2018/4/26
 * @github https://github.com/macrozheng
 */
@Controller
@RequestMapping("/admin")
public class UmsAdminController {
    
}

@Service

用于修饰service层的组件,service层组件专注于系统业务逻辑的处理,同样会被组件扫描并生成实例化对象。

/**
 * @auther macrozheng
 * @description 后台用户管理Service实现类
 * @date 2018/4/26
 * @github https://github.com/macrozheng
 */
@Service
public class UmsAdminServiceImpl implements UmsAdminService {
    
}

@Repository

用于修饰dao层的组件,dao层组件专注于系统数据的处理,例如数据库中的数据,同样会被组件扫描并生成实例化对象。

/**
 * @auther macrozheng
 * @description 后台用户与角色关系管理自定义Dao
 * @date 2018/10/8
 * @github https://github.com/macrozheng
 */
@Repository
public interface UmsAdminRoleRelationDao {
    
}

@Component

用于修饰SpringBoot中的组件,会被组件扫描并生成实例化对象。@Controller@Service@Repository都是特殊的组件注解。

/**
 * @auther macrozheng
 * @description 取消订单消息的生产者组件
 * @date 2018/9/14
 * @github https://github.com/macrozheng
 */
@Component
public class CancelOrderSender {
    
}

依赖注入注解

@Autowired

会根据对象的类型自动注入依赖对象,默认要求注入对象实例必须存在,可以配置required=false来注入不一定存在的对象。

/**
 * @auther macrozheng
 * @description 后台用户管理Controller
 * @date 2018/4/26
 * @github https://github.com/macrozheng
 */
@Controller
@RequestMapping("/admin")
public class UmsAdminController {
    @Autowired
    private UmsAdminService adminService;
}

@Resource

默认会根据对象的名称自动注入依赖对象,如果想要根据类型进行注入,可以设置属性为type = UmsAdminService.class

/**
 * @auther macrozheng
 * @description 后台用户管理Controller
 * @date 2018/4/26
 * @github https://github.com/macrozheng
 */
@Controller
@RequestMapping("/admin")
public class UmsAdminController {
    @Autowired
    @Resource(name = "umsAdminServiceImpl")
    private UmsAdminService adminService;
}

@Qualifier

当同一个对象有多个实例可以注入时,使用@Autowired注解无法进行注入,这时可以使用@Qualifier注解指定实例的名称进行精确注入。

/**
 * @auther macrozheng
 * @description 后台用户管理Controller
 * @date 2018/4/26
 * @github https://github.com/macrozheng
 */
@Controller
@RequestMapping("/admin")
public class UmsAdminController {
    @Autowired
    @Qualifier("umsAdminServiceImpl")
    private UmsAdminService adminService;
}

实例与生命周期相关注解

@Bean

用于修饰方法,标识该方法会创建一个Bean实例,并交给Spring容器来管理。

/**
 * @auther macrozheng
 * @description RestTemplate相关配置
 * @date 2018/4/26
 * @github https://github.com/macrozheng
 */
@Configuration
public class RestTemplateConfig {
    @Bean
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }
}

@Scope

用于声明一个SpringBean实例的作用域,作用域的范围有以下几种:

  • singleton:单例模式,在Spring容器中该实例唯一,Spring默认的实例模式。
  • prototype:原型模式,每次使用实例都将重新创建。
  • request:在同一请求中使用相同的实例,不同请求重新创建。
  • session:在同一会话中使用相同的实例,不同会话重新创建。
/**
 * @auther macrozheng
 * @description RestTemplate相关配置
 * @date 2018/4/26
 * @github https://github.com/macrozheng
 */
@Configuration
public class RestTemplateConfig {
    @Bean
    @Scope("singleton")
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }
}

@Primary

当同一个对象有多个实例时,优先选择该实例。

/**
 * @auther macrozheng
 * @description Jackson相关配置,配置json不返回null的字段
 * @date 2018/8/2
 * @github https://github.com/macrozheng
 */
@Configuration
public class JacksonConfig {
    @Bean
    @Primary
    @ConditionalOnMissingBean(ObjectMapper.class)
    public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) {
        ObjectMapper objectMapper = builder.createXmlMapper(false).build();
        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
        return objectMapper;
    }
}

@PostConstruct

用于修饰方法,当对象实例被创建并且依赖注入完成后执行,可用于对象实例的初始化操作。

@PreDestroy

用于修饰方法,当对象实例将被Spring容器移除时执行,可用于对象实例持有资源的释放。

@PostConstruct、@PreDestroy示例

/**
 * @auther macrozheng
 * @description 动态权限数据源,用于获取动态权限规则
 * @date 2020/2/7
 * @github https://github.com/macrozheng
 */
public class DynamicSecurityMetadataSource implements FilterInvocationSecurityMetadataSource {

    private static Map<String, ConfigAttribute> configAttributeMap = null;
    @Autowired
    private DynamicSecurityService dynamicSecurityService;

    @PostConstruct
    public void loadDataSource() {
        configAttributeMap = dynamicSecurityService.loadDataSource();
    }

    @PostConstruct
    public void loadDataSource() {
        configAttributeMap = dynamicSecurityService.loadDataSource();
    }

    @PreDestroy
    public void clearDataSource() {
        configAttributeMap.clear();
        configAttributeMap = null;
    }
}

SpringMVC相关注解

@RequestMapping

可用于将Web请求路径映射到处理类的方法上,当作用于类上时,可以统一类中所有方法的路由路径,当作用于方法上时,可单独指定方法的路由路径。

method属性可以指定请求的方式,如GET、POST、PUT、DELETE等。

@RequestBody

表示方法的请求参数为JSON格式,从Body中传入,将自动绑定到方法参数对象中。

@ResponseBody

表示方法将返回JSON格式的数据,会自动将返回的对象转化为JSON数据。

@RequestParam

用于接收请求参数,可以是如下三种形式:

  • query param:GET请求拼接在地址里的参数。
  • form data:POST表单提交的参数。
  • multipart:文件上传请求的部分参数。

@PathVariable

用于接收请求路径中的参数,常用于REST风格的API。

@RequestPart

用于接收文件上传中的文件参数,通常是multipart/form-data形式传入的参数。

/**
 * @auther macrozheng
 * @description MinIO对象存储管理Controller
 * @date 2019/12/25
 * @github https://github.com/macrozheng
 */
@Controller
@RequestMapping("/minio")
public class MinioController {

    @RequestMapping(value = "/upload", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult upload(@RequestPart("file") MultipartFile file) {
            //省略文件上传操作...
            return CommonResult.success(minioUploadDto);
    }
}

SpringMVC注解示例

/**
 * @auther macrozheng
 * @description 后台用户管理Controller
 * @date 2018/4/26
 * @github https://github.com/macrozheng
 */
@Controller
@RequestMapping("/admin")
public class UmsAdminController {

    @RequestMapping(value = "/register", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<UmsAdmin> register(@RequestBody UmsAdminParam umsAdminParam) {
        UmsAdmin umsAdmin = adminService.register(umsAdminParam);
        if (umsAdmin == null) {
            return CommonResult.failed();
        }
        return CommonResult.success(umsAdmin);
    }
    
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<CommonPage<UmsAdmin>> list(@RequestParam(value = "keyword", required = false) String keyword,
                                                   @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
                                                   @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
        List<UmsAdmin> adminList = adminService.list(keyword, pageSize, pageNum);
        return CommonResult.success(CommonPage.restPage(adminList));
    }

    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<UmsAdmin> getItem(@PathVariable Long id) {
        UmsAdmin admin = adminService.getItem(id);
        return CommonResult.success(admin);
    }
}

@RestController

用于表示controller层的组件,与@Controller注解的不同在于,相当于在每个请求处理方法上都添加了@ResponseBody注解,这些方法都将返回JSON格式数据。

@GetMapping

用于表示GET请求方法,等价于@RequestMapping(method = RequestMethod.GET)

@PostMapping

用于表示POST请求方法,等价于@RequestMapping(method = RequestMethod.POST)

REST风格注解示例

/**
 * @auther macrozheng
 * @description 后台用户管理Controller
 * @date 2018/4/26
 * @github https://github.com/macrozheng
 */
@RestController
@RequestMapping("/admin")
public class UmsAdminController {

    @PostMapping("/register")
    public CommonResult<UmsAdmin> register(@RequestBody UmsAdminParam umsAdminParam) {
        UmsAdmin umsAdmin = adminService.register(umsAdminParam);
        if (umsAdmin == null) {
            return CommonResult.failed();
        }
        return CommonResult.success(umsAdmin);
    }

    @GetMapping("/list")
    public CommonResult<CommonPage<UmsAdmin>> list(@RequestParam(value = "keyword", required = false) String keyword,
                                                   @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
                                                   @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
        List<UmsAdmin> adminList = adminService.list(keyword, pageSize, pageNum);
        return CommonResult.success(CommonPage.restPage(adminList));
    }
}

配置相关注解

@Configuration

用于声明一个Java形式的配置类,SpringBoot推荐使用Java配置,在该类中声明的Bean等配置将被SpringBoot的组件扫描功能扫描到。

/**
 * @auther macrozheng
 * @description MyBatis相关配置
 * @date 2019/4/8
 * @github https://github.com/macrozheng
 */
@Configuration
@MapperScan({"com.macro.mall.mapper","com.macro.mall.dao"})
public class MyBatisConfig {
}

@EnableAutoConfiguration

启用SpringBoot的自动化配置,会根据你在pom.xml添加的依赖和application-dev.yml中的配置自动创建你需要的配置。

@Configuration
@EnableAutoConfiguration
public class AppConfig {
}

@ComponentScan

启用SpringBoot的组件扫描功能,将自动装配和注入指定包下的Bean实例。

@Configuration
@ComponentScan({"xyz.erupt","com.macro.mall.tiny"})
public class EruptConfig {
}

@SpringBootApplication

用于表示SpringBoot应用中的启动类,相当于@EnableAutoConfiguration@EnableAutoConfiguration@ComponentScan三个注解的结合体。

@SpringBootApplication
public class MallTinyApplication {

    public static void main(String[] args) {
        SpringApplication.run(MallTinyApplication.class, args);
    }

}

@EnableCaching

当添加Spring Data Redis依赖之后,可用该注解开启Spring基于注解的缓存管理功能。

/**
 * @auther macrozheng
 * @description Redis配置类
 * @date 2020/3/2
 * @github https://github.com/macrozheng
 */
@EnableCaching
@Configuration
public class RedisConfig extends BaseRedisConfig {

}

@value

用于注入在配置文件中配置好的属性,例如我们可以在application.yml配置如下属性:

jwt:
  tokenHeader: Authorization #JWT存储的请求头
  secret: mall-admin-secret #JWT加解密使用的密钥
  expiration: 604800 #JWT的超期限时间(60*60*24*7)
  tokenHead: 'Bearer '  #JWT负载中拿到开头

然后在Java类中就可以使用@Value注入并进行使用了。

public class JwtTokenUtil {
    @Value("${jwt.secret}")
    private String secret;
    @Value("${jwt.expiration}")
    private Long expiration;
    @Value("${jwt.tokenHead}")
    private String tokenHead;
}

@ConfigurationProperties

用于批量注入外部配置,以对象的形式来导入指定前缀的配置,比如这里我们在application.yml中指定了secure.ignored为前缀的属性:

secure:
  ignored:
    urls: #安全路径白名单
      - /swagger-ui/
      - /swagger-resources/**
      - /**/v2/api-docs
      - /**/*.html
      - /**/*.js
      - /**/*.css
      - /**/*.png
      - /**/*.map
      - /favicon.ico
      - /actuator/**
      - /druid/**

然后在Java类中定义一个urls属性就可以导入配置文件中的属性了。

/**
 * @auther macrozheng
 * @description SpringSecurity白名单资源路径配置
 * @date 2018/11/5
 * @github https://github.com/macrozheng
 */
@Getter
@Setter
@Configuration
@ConfigurationProperties(prefix = "secure.ignored")
public class IgnoreUrlsConfig {

    private List<String> urls = new ArrayList<>();

}

@Conditional

用于表示当某个条件满足时,该组件或Bean将被Spring容器创建,下面是几个常用的条件注解。

  • @ConditionalOnBean:当某个Bean存在时,配置生效。
  • @ConditionalOnMissingBean:当某个Bean不存在时,配置生效。
  • @ConditionalOnClass:当某个类在Classpath存在时,配置生效。
  • @ConditionalOnMissingClass:当某个类在Classpath不存在时,配置生效。
/**
 * @auther macrozheng
 * @description Jackson相关配置,配置json不返回null的字段
 * @date 2018/8/2
 * @github https://github.com/macrozheng
 */
@Configuration
public class JacksonConfig {
    @Bean
    @Primary
    @ConditionalOnMissingBean(ObjectMapper.class)
    public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) {
        ObjectMapper objectMapper = builder.createXmlMapper(false).build();
        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
        return objectMapper;
    }
}

数据库事务相关注解

@EnableTransactionManagement

启用Spring基于注解的事务管理功能,需要和@Configuration注解一起使用。

/**
 * @auther macrozheng
 * @description MyBatis相关配置
 * @date 2019/4/8
 * @github https://github.com/macrozheng
 */
@Configuration
@EnableTransactionManagement
@MapperScan({"com.macro.mall.mapper","com.macro.mall.dao"})
public class MyBatisConfig {
}

@Transactional

表示方法和类需要开启事务,当作用与类上时,类中所有方法均会开启事务,当作用于方法上时,方法开启事务,方法上的注解无法被子类所继承。

/**
 * @auther macrozheng
 * @description 前台订单管理Service
 * @date 2018/8/30
 * @github https://github.com/macrozheng
 */
public interface OmsPortalOrderService {

    /**
     * 根据提交信息生成订单
     */
    @Transactional
    Map<String, Object> generateOrder(OrderParam orderParam);
}

SpringSecurity相关注解

@EnableWebSecurity

启用SpringSecurity的Web功能。

@EnableGlobalMethodSecurity

启用SpringSecurity基于方法的安全功能,当我们使用@PreAuthorize修饰接口方法时,需要有对应权限的用户才能访问。

SpringSecurity配置示例

/**
 * @auther macrozheng
 * @description SpringSecurity配置
 * @date 2019/10/8
 * @github https://github.com/macrozheng
 */
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfig{
    
}

全局异常处理注解

@ControllerAdvice

常与@ExceptionHandler注解一起使用,用于捕获全局异常,能作用于所有controller中。

@ExceptionHandler

修饰方法时,表示该方法为处理全局异常的方法。

全局异常处理示例

/**
 * @auther macrozheng
 * @description 全局异常处理
 * @date 2020/2/27
 * @github https://github.com/macrozheng
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    @ResponseBody
    @ExceptionHandler(value = ApiException.class)
    public CommonResult handle(ApiException e) {
        if (e.getErrorCode() != null) {
            return CommonResult.failed(e.getErrorCode());
        }
        return CommonResult.failed(e.getMessage());
    }
}

AOP相关注解

@Aspect

用于定义切面,切面是通知和切点的结合,定义了何时、何地应用通知功能。

@Before

表示前置通知(Before),通知方法会在目标方法调用之前执行,通知描述了切面要完成的工作以及何时执行。

@After

表示后置通知(After),通知方法会在目标方法返回或抛出异常后执行。

@AfterReturning

表示返回通知(AfterReturning),通知方法会在目标方法返回后执行。

@AfterThrowing

表示异常通知(AfterThrowing),通知方法会在目标方法返回后执行。

@Around

表示环绕通知(Around),通知方法会将目标方法封装起来,在目标方法调用之前和之后执行自定义的行为。

@Pointcut

定义切点表达式,定义了通知功能被应用的范围。

@Order

用于定义组件的执行顺序,在AOP中指的是切面的执行顺序,value属性越低优先级越高。

AOP相关示例

/**
 * @auther macrozheng
 * @description 统一日志处理切面
 * @date 2018/4/26
 * @github https://github.com/macrozheng
 */
@Aspect
@Component
@Order(1)
public class WebLogAspect {
    private static final Logger LOGGER = LoggerFactory.getLogger(WebLogAspect.class);

    @Pointcut("execution(public * com.macro.mall.tiny.controller.*.*(..))")
    public void webLog() {
    }

    @Before("webLog()")
    public void doBefore(JoinPoint joinPoint) throws Throwable {
    }

    @AfterReturning(value = "webLog()", returning = "ret")
    public void doAfterReturning(Object ret) throws Throwable {
    }

    @Around("webLog()")
    public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
        WebLog webLog = new WebLog();
        //省略日志处理操作...
        Object result = joinPoint.proceed();
        LOGGER.info("{}", JSONUtil.parse(webLog));
        return result;
    }
    
}

测试相关注解

@SpringBootTest

用于指定测试类启用Spring Boot Test功能,默认会提供Mock环境。

@Test

指定方法为测试方法。

测试示例

/**
 * @auther macrozheng
 * @description JUnit基本测试
 * @date 2022/10/11
 * @github https://github.com/macrozheng
 */
@SpringBootTest
public class FirstTest {
    @Test
    public void test() {
        int a=1;
        Assertions.assertEquals(1,a);
    }
}

总结

这些SpringBoot注解基本都是我平时做项目常用的注解,在我的电商实战项目mall中基本都用到了,这里做了一番整理归纳,希望对大家有所帮助!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/102579.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

《c专家编程》读书笔记

《c专家编程》第一章 C&#xff1a;穿越时空的迷雾第二章 这不是Bug&#xff0c;而是语言特性gets实验第三章 分析C语言的声明const实验第四章 令人震惊的事实&#xff1a;数组和指针并不相同指针与数组实验第五章 对链接的思考简单静态库动态库实验第六章 运动的诗章&#xff…

python-(6-5-3)爬虫---修改代码

文章目录一 事件背景二 系统给的代码三 改进措施四 改进后的代码一 事件背景 本篇主要是生活分享。 公司研究了一个比较好玩的人工智能狗&#xff0c;我就想偷懒让它帮我写个代码&#xff0c;得到的漂亮小姐姐的照片&#xff0c;然后它还真的给我把代码弄出来了。 二 系统给的…

​九州一轨通过注册:计划募资6.57亿 京投公司为大股东

雷递网 雷建平 12月19日北京九州一轨环境科技股份有限公司(简称&#xff1a;“九州一轨”&#xff09;日前通过注册&#xff0c;准备在科创板上市。九州一轨计划募资6.57亿元&#xff0c;其中&#xff0c;2.79亿元用于噪声与振动综合控制产研基地建设项目&#xff0c;1.43亿元用…

[附源码]计算机毕业设计Python飞越青少儿兴趣培训机构管理系统(程序+源码+LW文档)

该项目含有源码、文档、程序、数据库、配套开发软件、软件安装教程 项目运行 环境配置&#xff1a; Pychram社区版 python3.7.7 Mysql5.7 HBuilderXlist pipNavicat11Djangonodejs。 项目技术&#xff1a; django python Vue 等等组成&#xff0c;B/S模式 pychram管理等等…

我的一周年创作纪念日

机缘 第一次写文章的时候&#xff0c;CSDN还是我平时课程设计的救星&#xff1b;第一次写文章的时候&#xff0c;还不知道有什么拿得出手、可以和大家分享的&#xff1b;第一次写文章的时候&#xff0c;幻想着自己一觉醒来就坐拥10w粉丝&#xff0c;哈哈哈。感谢自己曾经冒出的…

【实践】推荐、搜索、广告多业务多场景统一预估引擎实践与思考

省时查报告-专业、及时、全面的行研报告库省时查方案-专业、及时、全面的营销策划方案库【免费下载】2022年11月份热门报告盘点《底层逻辑》高清配图‍基于深度学习的个性化推荐系统实时化改造与升级.pdf推荐技术在vivo互联网商业化业务中的实践.pdf推荐系统基本问题及系统优化…

元认知神经网络与在线序贯学习(Matlab代码实现)

目录 &#x1f4a5;1 概述 &#x1f4da;2 运行结果 &#x1f389;3 参考文献 &#x1f468;‍&#x1f4bb;4 Matlab代码 &#x1f4a5;1 概述 文章包含用于实现自适应识别和控制的在线顺序学习算法、元认知神经网络和前馈神经网络的代码。这些方法也用于解决分类和时间序…

[附源码]计算机毕业设计Node.js仓库管理系统(程序+LW)

项目运行 环境配置&#xff1a; Node.js最新版 Vscode Mysql5.7 HBuilderXNavicat11Vue。 项目技术&#xff1a; Express框架 Node.js Vue 等等组成&#xff0c;B/S模式 Vscode管理前后端分离等等。 环境需要 1.运行环境&#xff1a;最好是Nodejs最新版&#xff0c;我…

【docker】CMD和ENTRYPOINT的区别

1、测试cmd #编写 dockerfile 文件 [rootkuangshen docekrfile]# vim dockerfile-cmd-test FROM centos CMD ["ls","-a"] #构建镜像 [rootkuangshen dockerfile]# docker build -f dockerfile-cmd-test -t cmdtest . #run运行&#xff0c;发现我们的ls -a …

你为什么一定要学Python?

我们为什么要学习Python&#xff1f; 在农业社会时&#xff0c;我们要学习驾驭马、驴、牛&#xff0c;让它们为我们出力、干活。 在工业社会时&#xff0c;我们要学会驾驭各种机器、火车、轮船、飞机、机床等等。 今天&#xff0c;我们要让机器听我们的指挥&#xff0c;我们就…

Python图像处理【5】图像扭曲/逆扭曲

图像扭曲/逆扭曲0. 前言1. 使用 scikit-image warp() 函数执行图像变换1.1 scikit-image warp() 函数原理1.2 利用 warp() 函数实现图像变换2. 漩涡变换详解2.1 旋涡变换原理2.2 使用 scikit-image warp() 实现旋涡变换2.3 使用 scipy.ndimage 实现漩涡变换3. 使用 scikit-imag…

3ds Max:加强型文本

3ds Max 中的加强型文本 TextPlus工具能够实现非常多的功能。在 3ds Max 中&#xff0c;加强型文本也是标准基本体。新建加强型文本后&#xff0c;可以看到其相关参数&#xff0c;在下方可以更改文本的内容外观。插值Interpolation步数Steps用来控制文本图形线段间的端点数&…

[附源码]计算机毕业设计Python高校流浪动物领养网站(程序+源码+LW文档)

该项目含有源码、文档、程序、数据库、配套开发软件、软件安装教程 项目运行 环境配置&#xff1a; Pychram社区版 python3.7.7 Mysql5.7 HBuilderXlist pipNavicat11Djangonodejs。 项目技术&#xff1a; django python Vue 等等组成&#xff0c;B/S模式 pychram管理等…

MySQL基础操作汇总(干货)

数据库操作&#xff1a; 1)创建数据库&#xff1a;create database数据库名; 2)查看所有数据库&#xff1a;show databases; 3)选中指定数据库&#xff1a;use 数据库名; 4)删除数据库&#xff1a; drop database数据库名; 数据表操作 1)创建表&#xff1a;create table表…

Mycat(7):分片详解之枚举

1 分片思路 打开rule.xml 文件&#xff0c;找到对呀的分片规则&#xff0c;如&#xff1a;sharding-by-intfile 标签含义&#xff1a; columns:代表数据库里面的字段名 algorithm&#xff1a;分片算法 找到rule.xml文件中的hash-int分片算法地址&#xff0c;指向文件partition-…

满大街都在叫我学Python,真有必要学吗?

前言 前一段时间在网上看到非常多的推广&#xff0c;无一例外都是分享自己学python的经历&#xff0c;告诉你自己学了之后&#xff0c;无一例外都是说找工作好找&#xff0c;需求多&#xff0c;2个小时的工作5分钟就做完了&#xff0c;找资料要30分钟&#xff0c;学会之后只要…

数据中心网络学习资料

目录 该文章持续更新&#xff0c;收集了一些比较好的与数据中心相关的文章和课程。 文章&#xff1a; 老网工&#xff1a;浅谈数据中心云网技术的历经风雨和演进&#xff1a;https://www.sdnlab.com/22920.html 数据中心网络架构浅谈&#xff08;一&#xff09;&#xff1a;…

2022年seo优化怎么做:百度官方给出解答

最近百度搜索平台最近对站长圈部分站长进行了SEO、网络建站、搜索合作等方向的经验征集,2022年seo优化怎么做,对于站长们今年网站优化提供了新的思路,非常值得参考: 2022年对于SEO从业者而言,需要将更多的精力聚焦在流量的变化上,这可能是不平凡的一年,作为站长后续在网…

自动驾驶专题介绍 ———— 制动系统

制动系统 使行驶中的汽车减速甚至停车&#xff0c;使下坡行驶的汽车保持速度稳定&#xff0c;以及使已停驶的汽车保持不动&#xff0c;这些作用统称为汽车制动。而对汽车进行制动的外力来源则是制动系统。  制动系统由制动器和制动驱动机构构成。制动器是指产生阻碍车辆运动或…

微服务框架 SpringCloud微服务架构 微服务面试篇 54 微服务篇 54.8 Sentinel的限流与Gateway的限流有什么差别?

微服务框架 【SpringCloudRabbitMQDockerRedis搜索分布式&#xff0c;系统详解springcloud微服务技术栈课程|黑马程序员Java微服务】 微服务面试篇 文章目录微服务框架微服务面试篇54 微服务篇54.8 Sentinel的限流与Gateway的限流有什么差别&#xff1f;54.8.1 限流与常见 限…