• No6.从零搭建spring-cloud-alibaba微服务框架,实现数据库调用、用户认证与授权等(二,no6-2)


     代码地址与接口看总目录:【学习笔记】记录冷冷-pig项目的学习过程,大概包括Authorization Server、springcloud、Mybatis Plus~~~_清晨敲代码的博客-CSDN博客

    之前只零碎的学习过spring-cloud-alibaba,并没有全面了解过,这次学习pig框架时,想着可以根据这个项目学习一下,练练手,于是断断续续的用了几天时间搭建了一下基础框架。目前就先重点记录一下遇到的问题吧,毕竟流程也不是特别复杂,就是有的东西没遇到过了解的也不深~

    上篇文章:No6.从零搭建spring-cloud-alibaba微服务框架,实现fegin、gateway、springevent等(一)_清晨敲代码的博客-CSDN博客

    上篇文章包括:

    1.将服务系统注册到nacos注册中心;

    2.通过nacos实现配置动态更新;

    3.添加fegin服务,实现服务之间调用;

    4.添加网关(学会使用webflux,学会添加过滤器);

    5.添加log服务,通过springevent实现,并使用注解使用(使用AOP);

    本篇文章包括:

    6.添加 mysql 数据库调用,并使用mybatis-plus操作;

    7.在认证模块添加用户认证,基于oauth2的自定义密码模式(已认证用户是基于自定义token加redis持久化,不是session);

    剩余包括(会有变动):

    8.在upms资源模块添加对accesstoken校验逻辑,使用spring-security-oauth2-resource-server的BearerTokenAuthenticationFilter逻辑加上自定义校验token逻辑;

    9.添加用户权限校验等逻辑,需要考虑微服务内部调用不鉴权逻辑;

    目录

    A6.添加 mysql 数据库调用,并使用mybatis-plus操作;

    需要记住的问题:

    A7.添加用户认证,基于oauth2的自定义密码模式(已认证用户是基于自定义token加redis持久化,不是session);

    遇到的问题:

    自定义密码认证过滤器的调用图:


    A6.添加 mysql 数据库调用,并使用mybatis-plus操作;

    添加pig-common-mybatis模块,主要处理mybatis-plus的配置,不配置这个也是可以的。

    具体的mysql数据库调用在pig-upms-biz模块。

    先来看基本的使用步骤

    1.导包

    2.添加数据库实体类;

    3.添加mapper接口,可以继承mps提供的BaseMapper,也可以添加自定义mapper.xml;并让其被扫描到

    4.添加service类,自定义后可以继承mps提供的IService和ServiceImpl;并添加到容器中

    5.在controller中使用;

    6.在application.xml中配置mapper-locations来扫描Mapper接口对应的XML文件,和其他mps配置信息;

    1. <dependency>
    2. <groupId>com.baomidougroupId>
    3. <artifactId>mybatis-plus-boot-starterartifactId>
    4. dependency>
    5. <dependency>
    6. <groupId>mysqlgroupId>
    7. <artifactId>mysql-connector-javaartifactId>
    8. dependency>
    1. //2.基础实体类,类似于创建时间等内容
    2. @Getter
    3. @Setter
    4. public class BaseEntity implements Serializable {
    5. /**
    6. * 创建者
    7. */
    8. @TableField(fill = FieldFill.INSERT)
    9. private String createBy;
    10. /**
    11. * 创建时间
    12. */
    13. @TableField(fill = FieldFill.INSERT)
    14. private LocalDateTime createTime;
    15. /**
    16. * 更新者
    17. */
    18. @TableField(fill = FieldFill.INSERT_UPDATE)
    19. private String updateBy;
    20. /**
    21. * 更新时间
    22. */
    23. @TableField(fill = FieldFill.INSERT_UPDATE)
    24. private LocalDateTime updateTime;
    25. }
    26. @Data
    27. @EqualsAndHashCode(callSuper = true)
    28. public class SysUser extends BaseEntity {
    29. private static final long serialVersionUID = 1L;
    30. /**
    31. * 主键ID
    32. */
    33. @TableId(value = "user_id", type = IdType.AUTO)
    34. private Long userId;
    35. /**
    36. * 用户名
    37. */
    38. private String username;
    39. 。。。
    40. /**
    41. * 0-正常,1-删除
    42. */
    43. @TableLogic(value = "0", delval = "4")
    44. private String delFlag;
    45. }
    1. //3.继承mps提供的 BaseMapper ,就可以使用他默认提供的方法。同时也可以添加 mapper.xml ,使用自定义的方法
    2. //要么添加 @Mapper,要么添加@Mapperscan
    3. @Mapper
    4. public interface SysUserMapper extends BaseMapper {
    5. /**
    6. * @Description: 通过ID查询用户信息
    7. * @param id
    8. * @Return: com.pig4cloud.pig.admin.api.vo.UserVO
    9. */
    10. UserVO getUserVoById(Long id);
    11. /**
    12. * @Description: 分页查询用户信息(含角色)
    13. * @param page
    14. * @param userDTO
    15. * @Return: com.baomidou.mybatisplus.core.metadata.IPage
    16. */
    17. IPage getUserVosPage(Page page, @Param("query") UserDTO userDTO);
    18. }
    1. //4.添加service类,自定义后可以继承mps提供的IService和ServiceImpl;并添加到容器中
    2. //接口类和impl实现类都需要实现mps提供的类,然后就可以使用mps的service提供的方法
    3. public interface SysUserService extends IService {
    4. /**
    5. * @Description: 新增/保存用户信息
    6. * @param userDto
    7. * @Return: java.lang.Boolean
    8. */
    9. Boolean saveUser(UserDTO userDto);
    10. }
    11. @Slf4j
    12. @Service
    13. @RequiredArgsConstructor
    14. public class SysUserServiceImpl extends ServiceImpl implements SysUserService {
    15. private static final PasswordEncoder ENCODER = new BCryptPasswordEncoder();
    16. /**
    17. * @Description: 新增/保存用户信息
    18. * @param userDto
    19. * @Return: java.lang.Boolean
    20. */
    21. @Override
    22. public Boolean saveUser(UserDTO userDto) {
    23. SysUser sysUser = new SysUser();
    24. BeanUtils.copyProperties(userDto, sysUser);
    25. sysUser.setDelFlag(CommonConstants.STATUS_NORMAL);
    26. sysUser.setPassword(ENCODER.encode(userDto.getPassword()));
    27. //this.save(sysUser); 这俩有舍区别? service.save() 内部调用的也是 basesmapper.insert()
    28. baseMapper.insert(sysUser);
    29. //这里可以处理用户其他关联信息
    30. return Boolean.TRUE;
    31. }
    32. }
    1. //5.在controller中使用;
    2. @RestController
    3. @RequiredArgsConstructor
    4. @RequestMapping("/user")
    5. public class UserController {
    6. private final SysUserService userService;
    7. /**
    8. * @Description: 添加用户
    9. * @param userDto
    10. * @Return: com.pig4cloud.pig.common.core.util.R
    11. */
    12. @SysLog("添加用户")
    13. @PostMapping
    14. public R user(@RequestBody UserDTO userDto) {
    15. SysUser sysUser = userService.getOne(Wrappers.lambdaQuery().eq(SysUser::getUsername,userDto.getUsername()));
    16. if(sysUser != null){
    17. return R.failed("用户名已存在");
    18. }
    19. sysUser = userService.getOne(Wrappers.lambdaQuery().eq(SysUser::getPhone,userDto.getPhone()));
    20. if(sysUser != null){
    21. return R.failed("手机号码已存在");
    22. }
    23. return R.ok(userService.saveUser(userDto));
    24. }
    25. }
    1. # 6.application.yml 或者 nacos 里面的配置文件里面,配置mybatis扫描mapper.xml文件
    2. mybatis-plus:
    3. # 默认和mapper接口所在的包名相同
    4. mapper-locations: classpath:/mapper/*Mapper.xml
    5. global-config:
    6. banner: false
    7. db-config:
    8. # 主键类型 AUTO:"数据库ID自增" INPUT:"用户输入ID",ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID";
    9. id-type: auto
    10. # 表名是否使用驼峰转下划线命名,只对表名生效。
    11. table-underline: true
    12. # 逻辑已删除值,(逻辑删除下有效)。
    13. logic-delete-value: 1
    14. # 逻辑未删除值,(逻辑删除下有效)。
    15. logic-not-delete-value: 0
    16. configuration:
    17. # 是否开启自动驼峰命名规则映射:从数据库列名到Java属性驼峰命名的类似映射
    18. map-underscore-to-camel-case: true

    最后使用 apifox 进行测试,完美实现。

    需要记住的问题:

    这里需要记住 mybatis-plus 里面的注解,例如 @TableId(value = "user_id", type = IdType.AUTO)   @TableLogic(value = "0", delval = "4")  @TableField(fill = FieldFill.INSERT) 等~还有配置文件里面的,需要详细的记住~

    还有就是原理需要搞明白。

    A7.添加用户认证,基于oauth2的自定义密码模式(已认证用户是基于自定义token加redis持久化,不是session);

    使用oauth2的方式实现密码模式的用户授权认证,暂时只校验是否身份认证,不进行权限设置。

    就是相当于用户通过密码模式获取到token ,测试时只需要测试这个接口即可。

    主要步骤有:

    1.导入oauth2依赖的包;

    2.在pig-common-secuity中添加获取用户信息的UserDetailsService自定义类,同时需要添加UserDetails的实现类;然后在pig-upms-biz中添加fegin接口,以及其相关的mybatis业务类;将需要到的service类添加到 META-INF/string.factories 中,以便添加到容器中;

    3.在pig-auth中添加用户身份认证provider(类似于DaoAuthenticationProvider),能够调用UserDetailsService,最终并返回已认证的Authentication;会使用到2.

    4.在pig-common-secuity中添加自定义的oauth2认证管理OAuth2AuthorizationService,他的主要作用是记录已认证的用户信息及使用的客户端信息,通过redis持久化;【放这个模块是为了资源端也能共用】,将service类添加到 META-INF/string.factories 中,以便添加到容器中;

    5.在pig-common-secuity中添加自定义的注册客户端的持久化管理 RegisteredClientRepository ,他的主要作用就是从数据库中获取已注册的客户端信息RegisteredClient;具体的增删改在pig-upms-biz业务中,这里只需要查询即可;将service类添加到 META-INF/string.factories 中,以便添加到容器中;

    6.在pig-auth中添加自定义OAuth2TokenGenerator生成器,若需要增强可以自定义OAuth2TokenCustomizer类;

    7.在pig-auth中添加oauth2资源端用户认证过程中需要的converter、provider、token,其中会使用到3.4.5.中的类;

    8.在pig-auth中添加自定义的AuthenticationFailureHandler、AuthenticationSuccessHandler的认证失败成功处理器;

    9.在pig-auth中添加认证服务器配置;

    1. <dependency>
    2. <groupId>org.springframework.securitygroupId>
    3. <artifactId>spring-security-oauth2-authorization-serverartifactId>
    4. <version>${spring.authorization.version}version>
    5. dependency>
    1. //2.pig-common-secuity
    2. com.pig4cloud.pig.common.security.service.PigUser extends User implements OAuth2AuthenticatedPrincipal
    3. com.pig4cloud.pig.common.security.service.PigUserDetailsService extends UserDetailsService, Ordered
    4. com.pig4cloud.pig.common.security.service.PigUserDetailsServiceImpl implements PigUserDetailsService
    5. //然后将这个实现类添加到 /resources/META-INF/spring.factories 里面,就能自动注入到使用的启动模块中
    6. org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
    7. com.pig4cloud.pig.common.security.service.PigUserDetailsServiceImpl
    8. //--------------
    9. //在 pig-upms-api 里面添加 openfegin 接口,也可以直接加到消费端 auth 里面;
    10. //这个接口直接就用用户模块里面的 获取用户全部信息(包括权限) = /user/info/{username}
    11. @FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.UMPS_SERVICE)
    12. com.pig4cloud.pig.admin.api.feign.auth.RemoteUserService
    1. //3.在 pig-auth 模块里面添加 provider,这个接口直接继承 AbstractUserDetailsAuthenticationProvider ,只需要重写获取用户信息方法、校验密码方法
    2. com.pig4cloud.pig.auth.support.core.PigDaoAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider{
    3. 会用到 PigUserDetailsServiceImpl 类型对象
    4. }
    1. //4.在pig-common-secuity中
    2. com.pig4cloud.pig.common.security.service.PigRedisOAuth2AuthorizationService implements OAuth2AuthorizationService{
    3. 里面会用到 redis ,会将产生的 accesstoken、refreshtoken、code、state等信息存到 redis里面
    4. private final RedisTemplate redisTemplate;
    5. }
    6. //然后将这个实现类添加到 /resources/META-INF/spring.factories 里面,就能自动注入到使用的启动模块中
    7. org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
    8. com.pig4cloud.pig.common.security.service.PigUserDetailsServiceImpl,\
    9. com.pig4cloud.pig.common.security.service.PigRedisOAuth2AuthorizationService,\
    10. com.pig4cloud.pig.common.security.service.PigRemoteRegisteredClientRepository
    11. //--------------
    12. //用到了 redis 就得添加 RedisTemplate 到容器中,在 pig-common-core 中添加 redis 配置
    13. com.pig4cloud.pig.common.core.config.RedisTemplateConfiguration{}
    14. //然后将这个 configuration 添加到 /resources/META-INF/spring.factories 里面,就能自动注入到使用的启动模块中
    15. org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
    16. com.pig4cloud.pig.common.core.config.JacksonConfiguration,\
    17. com.pig4cloud.pig.common.core.util.SpringContextHolder,\
    18. com.pig4cloud.pig.common.core.config.RedisTemplateConfiguration
    1. //5.在pig-common-secuity中
    2. com.pig4cloud.pig.common.security.service.PigRemoteRegisteredClientRepository implements RegisteredClientRepository{
    3. //从 upms 模块里面调用持久的客户端信息
    4. private final RemoteClientDetailsService clientDetailsService;
    5. }
    6. //然后将这个实现类添加到 /resources/META-INF/spring.factories 里面,就能自动注入到使用的启动模块中
    7. org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
    8. com.pig4cloud.pig.common.security.service.PigUserDetailsServiceImpl,\
    9. com.pig4cloud.pig.common.security.service.PigRedisOAuth2AuthorizationService,\
    10. com.pig4cloud.pig.common.security.service.PigRemoteRegisteredClientRepository
    11. //--------------
    12. //在 pig-upms-api 里面添加 openfegin 接口,也可以直接加到消费端 auth 里面;
    13. //这个接口直接就用用户模块里面的 获取某个客户端信息 = /client/getClientDetailsById/{clientId}
    14. @FeignClient(contextId = "remoteClientDetailsService", value = ServiceNameConstants.UMPS_SERVICE)
    15. com.pig4cloud.pig.admin.api.feign.auth.RemoteClientDetailsService
    1. //6. pig-auth
    2. com.pig4cloud.pig.auth.support.core.CustomeOAuth2AccessTokenGenerator implements OAuth2TokenGenerator
    3. com.pig4cloud.pig.auth.support.core.CustomeOAuth2AccessTokenGenerator.OAuth2AccessTokenClaims extends OAuth2AccessToken implements ClaimAccessor
    4. com.pig4cloud.pig.auth.support.core.CustomeOAuth2TokenCustomizer implements OAuth2TokenCustomizer
    1. //7.pig-auth
    2. //基类
    3. com.pig4cloud.pig.auth.support.base.OAuth2ResourceOwnerBaseAuthenticationToken extends AbstractAuthenticationToken{
    4. private final AuthorizationGrantType authorizationGrantType;
    5. //这里的是客户端认证信息
    6. private final Authentication clientPrincipal;
    7. private final Set scopes;
    8. private final Map additionalParameters;
    9. }
    10. com.pig4cloud.pig.auth.support.base.OAuth2ResourceOwnerBaseAuthenticationConverter< T extends OAuth2ResourceOwnerBaseAuthenticationToken> implements AuthenticationConverter
    11. com.pig4cloud.pig.auth.support.base.OAuth2ResourceOwnerBaseAuthenticationProvider extends OAuth2ResourceOwnerBaseAuthenticationToken> implements AuthenticationProvider{
    12. private final AuthenticationManager authenticationManager;
    13. private final OAuth2AuthorizationService oAuth2AuthorizationService;
    14. private final OAuth2TokenGeneratorextends OAuth2Token> oAuth2TokenGenerator;
    15. }
    16. //实现类
    17. com.pig4cloud.pig.auth.support.password.OAuth2ResourceOwnerPasswordAuthenticationToken extends OAuth2ResourceOwnerBaseAuthenticationToken
    18. com.pig4cloud.pig.auth.support.password.OAuth2ResourceOwnerPasswordAuthenticationConverter extends OAuth2ResourceOwnerBaseAuthenticationConverter
    19. com.pig4cloud.pig.auth.support.password.OAuth2ResourceOwnerPasswordAuthenticationProvider extends OAuth2ResourceOwnerBaseAuthenticationProvider
    1. //8. pig-auth
    2. com.pig4cloud.pig.auth.support.handler.PigAuthenticationSuccessEventHandler implements AuthenticationSuccessHandler
    3. com.pig4cloud.pig.auth.support.handler.PigAuthenticationFailureEventHandler implements AuthenticationFailureHandler
    1. //9. pig-auth 专门配置 oauth2认证的安全配置
    2. @EnableWebSecurity(debug = true) //这个注解会触发创建 HttpSecurity bean ~
    3. @RequiredArgsConstructor
    4. com.pig4cloud.pig.auth.config.AuthorizationServerConfiguration{
    5. private final OAuth2AuthorizationService authorizationService;
    6. private final RegisteredClientRepository registeredClientRepository;
    7. @Bean
    8. @Order(Ordered.HIGHEST_PRECEDENCE)
    9. SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
    10. OAuth2AuthorizationServerConfigurer authorizationServerConfigurer = new OAuth2AuthorizationServerConfigurer<>();
    11. //配置个性化客户端认证(根据请求参数判断是否可以客户端认证)
    12. http.apply(authorizationServerConfigurer.clientAuthentication((oAuth2ClientAuthenticationConfigurer) -> {
    13. //配置授权失败的处理器
    14. oAuth2ClientAuthenticationConfigurer.errorResponseHandler(new PigAuthenticationFailureEventHandler()); // 个性化客户端认证
    15. }));
    16. //配置个性化认证授权端点(获取 accestokende 的端点)
    17. http.apply(authorizationServerConfigurer.tokenEndpoint(oAuth2TokenEndpointConfigurer -> {
    18. oAuth2TokenEndpointConfigurer.accessTokenRequestConverter(accessTokenRequestConverter()) // 注入自定义的授权认证 Converter 转化器
    19. .accessTokenResponseHandler(new PigAuthenticationSuccessEventHandler()) //配置认证失败的处理器
    20. .errorResponseHandler(new PigAuthenticationFailureEventHandler());//配置认证成功的处理器
    21. }));
    22. //配置端点元数据统一发行路径,其中各个端点路径都有默认使用值(也可以自定义配置,例如使用.authorizationEndpoint()配置授权请求端点)
    23. http.apply(authorizationServerConfigurer.providerSettings(ProviderSettings.builder().issuer(SecurityConstants.PROJECT_LICENSE).build()));
    24. //配置自定义授权信息token持久化到redis的管理类(会放到http的share)
    25. http.apply(authorizationServerConfigurer.authorizationService(authorizationService));
    26. //配置已注册的客户端信息的管理类(会放到http的share)
    27. http.apply(authorizationServerConfigurer.registeredClientRepository(registeredClientRepository));
    28. //拿到aotuh2需要的endpoint端点
    29. RequestMatcher endpoint = authorizationServerConfigurer.getEndpointsMatcher();
    30. SecurityFilterChain securityFilterChain = http
    31. //配置过滤链拦截的端点(过滤链默认是任意端点,可以通过这个设置,只有匹配中这写端点,才会进入这个过滤链)
    32. .requestMatcher(endpoint)
    33. //配置端点的权限(默认提供的oauth2的端点是需要认证权限的,例如/oauth2/introspect)
    34. .authorizeRequests(authorizeRequests -> authorizeRequests.anyRequest().authenticated())
    35. // .formLogin()
    36. // .and()
    37. .csrf().disable()
    38. //build SecurityFilterChain
    39. .build();
    40. //注入所有自定义认证授权需要的 provider 对象
    41. addCustomOAuth2GrantAuthenticationProvider(http);
    42. return securityFilterChain;
    43. }
    44. /**
    45. * @Description: request -> xToken 注入请求转换器
    46. * 1、授权码模式(暂无)
    47. * 2、隐藏式(暂无)
    48. * 3、密码式(自定义的)
    49. * 4、客户端凭证(暂无)
    50. * @param
    51. * @Return: org.springframework.security.web.authentication.AuthenticationConverter
    52. */
    53. public AuthenticationConverter accessTokenRequestConverter(){
    54. //new一个token转换器委托器,其中包含自定义密码模式认证转换器和刷新令牌认证转换器
    55. return new DelegatingAuthenticationConverter(Arrays.asList(
    56. new OAuth2ResourceOwnerPasswordAuthenticationConverter(),
    57. // 访问令牌请求用于OAuth 2.0刷新令牌授权 ——刷新token
    58. new OAuth2RefreshTokenAuthenticationConverter()
    59. //有需要到就要添加上
    60. // // 访问令牌请求用于OAuth 2.0授权码授权 ——授权码模式获取token
    61. // new OAuth2AuthorizationCodeAuthenticationConverter(),
    62. // // 授权请求(或同意)用于OAuth 2.0授权代码授权 ——授权码模式获取code
    63. // new OAuth2AuthorizationCodeRequestAuthenticationConverter()
    64. ));
    65. }
    66. /**
    67. * @Description: 注入所有自定义认证授权需要的 provider 对象
    68. * 1. 密码模式
    69. * 2. 短信登录 (暂无)
    70. * @param http
    71. * @Return: void
    72. */
    73. public void addCustomOAuth2GrantAuthenticationProvider(HttpSecurity http){
    74. //从shareObject中获取到授权管理业务类(主要负责管理已认证的授权信息)
    75. OAuth2AuthorizationService oAuth2AuthorizationService = http.getSharedObject(OAuth2AuthorizationService.class);
    76. //从shareObject中获取到认证管理类
    77. AuthenticationManager authenticationManager = http.getSharedObject(AuthenticationManager.class);
    78. //new一个自定义处理密码模式的授权提供方,其中重点需要注入token生成器
    79. OAuth2ResourceOwnerPasswordAuthenticationProvider oAuth2ResourceOwnerPasswordAuthenticationProvider =
    80. new OAuth2ResourceOwnerPasswordAuthenticationProvider(authenticationManager, oAuth2AuthorizationService, oAuth2TokenGenerator());
    81. // 将自定义处理密码模式的授权提供方添加到安全配置中
    82. http.authenticationProvider(new PigDaoAuthenticationProvider());
    83. // 将自定义用户认证提供方添加到安全配置中
    84. http.authenticationProvider(oAuth2ResourceOwnerPasswordAuthenticationProvider);
    85. }
    86. /**
    87. * @Description: 令牌生成规则实现
    88. * @param
    89. * @Return: OAuth2TokenGenerator
    90. */
    91. @Bean
    92. public OAuth2TokenGenerator oAuth2TokenGenerator(){
    93. CustomeOAuth2AccessTokenGenerator customeOAuth2AccessTokenGenerator = new CustomeOAuth2AccessTokenGenerator();
    94. customeOAuth2AccessTokenGenerator.setAccessTokenCustomizer(new CustomeOAuth2TokenCustomizer());
    95. //new一个token生成器委托器,其中包含自定义accesstoken生成器和refreshtoken生成器
    96. return new DelegatingOAuth2TokenGenerator(customeOAuth2AccessTokenGenerator,new OAuth2RefreshTokenGenerator());
    97. }
    98. }

    最终在apifox 里面进行访问,/oauth2/token是 authorization-server 默认的获取token端点:

    1.请求:127.0.0.1:3001/oauth2/token

    2.query:grant_type=password&scope=server&randomStr=1234567&code=1

    3.body:username=admin ;password=YehdBPev

    4.basic auth:Basic dGVzdDp0ZXN0

     成功~

    遇到的问题:

    1.OAuth2Authorization的属性总记不住,要知道里面的token是存到 Map 类型里面的;

    2.openfeign的使用,需要两个注解:@EnableFeignClients(basePackages="扫描注入@FeignClient注解对象")、@FeignClient。如果只添加@FeignClient注解而没有添加@EnableFeignClients,则@FeignClient注解的类就是个普通对象。

    自定义密码认证过滤器的调用图:

    防止忘记,写一下~

     

  • 相关阅读:
    mysql高级刷题-01-求中位数
    华为云云耀云服务器L实例评测|从零快速搭建个人博客指南
    关于vue.config.js
    struts2绕过waf读写文件及另类方式执行命令
    360crawlergo结合xray被动扫描
    OpenAI推出首个AI视频模型Sora:重塑视频创作与体验
    Springboot毕设项目校园跑腿网站013tujava+VUE+Mybatis+Maven+Mysql+sprnig)
    redis(13)持久化操作-AOF
    Java类的初始化过程
    稀土掺杂氟化物纳米荧光微球/稀土荧光磁性纳米微球Fe3O4@PHEMA-RE的制备方法
  • 原文地址:https://blog.csdn.net/vaevaevae233/article/details/127441970