当前位置: 首页 > news >正文

网站空间ip查询微信做网站的公司

网站空间ip查询,微信做网站的公司,泰安集团网站建设方案,营销型网站的作用EnableConfigurationProperties ConfigurationProperties的使用时机 今天在写properties时想到了这个问题#xff0c;为什么有时候我需要写EnableConfigurationProperties有时候又不需要呢#xff1f;下面就详细讲讲。 Data Component ConfigurationProperties(pr…EnableConfigurationProperties ConfigurationProperties的使用时机 今天在写properties时想到了这个问题为什么有时候我需要写EnableConfigurationProperties有时候又不需要呢下面就详细讲讲。 Data Component ConfigurationProperties(prefix hm.auth) public class AuthProperties {private ListString includePaths;private ListString excludePaths; }Component RequiredArgsConstructor public class AuthGlobalFilter implements GlobalFilter, Ordered {private final AuthProperties authProperties;private final JwtTool jwtTool;private final AntPathMatcher antPathMatcher new AntPathMatcher();可以看到AuthGlobalFilter并没有添加EnableConfigurationProperties只是简单的注入就可以使用。 Data ConfigurationProperties(prefix hm.jwt) public class JwtProperties {private Resource location;private String password;private String alias;private Duration tokenTTL Duration.ofMinutes(10); }Configuration EnableConfigurationProperties(JwtProperties.class) public class SecurityConfig {Beanpublic PasswordEncoder passwordEncoder(){return new BCryptPasswordEncoder();}Beanpublic KeyPair keyPair(JwtProperties properties){// 获取秘钥工厂KeyStoreKeyFactory keyStoreKeyFactory new KeyStoreKeyFactory(properties.getLocation(),properties.getPassword().toCharArray());//读取钥匙对return keyStoreKeyFactory.getKeyPair(properties.getAlias(),properties.getPassword().toCharArray());} }可以看到JwtProperties没有添加Component注解也就是没有注册为 Spring 容器中的 bean。然后SecurityConfig中就添加了EnableConfigurationProperties(JwtProperties.class)然后在下面方法中通过参数自动注入public KeyPair keyPair(JwtProperties properties)。 为什么需要 EnableConfigurationProperties 默认情况下使用 ConfigurationProperties 标注的类不会被自动注册为 Spring 容器中的 bean。使用 EnableConfigurationProperties(SecurityConfigProperties.class) 会将该类注册为一个 Spring 管理的 bean使它能够被自动注入。 因为前面JwtProperties没有添加Component注解所以需要添加 EnableConfigurationProperties。而AuthProperties有Component注解也就是已经被spring管理了所以不需要额外添加。 简化方式 如果 SecurityConfigProperties 类本身已经用 Component 标注则无需额外使用 EnableConfigurationProperties。 示例 Component ConfigurationProperties(prefix security) public class SecurityConfigProperties {// 属性和 Getter/Setter 同前 }在这种情况下EnableConfigurationProperties 就变得非必需。 但是如果为了更加稳妥可以把这两个注解全部都加上。Configuration和Component 都可以使其被spring容器管理。 Slf4j Data ConfigurationProperties(prefix zzyl.framework.security) Configuration public class SecurityConfigProperties { }Configuration EnableConfigurationProperties(SecurityConfigProperties.class) public class SecurityConfig {AutowiredSecurityConfigProperties securityConfigProperties;AutowiredJwtAuthorizationManager jwtAuthorizationManager;
http://www.hkea.cn/news/14452417/

相关文章:

  • 视频网站开发需要什么插件网站开发音乐
  • 网站建设和优化容桂商城网站建设
  • 石柱县建设局网站做胃镜需那好天津津门网站A
  • 网站开发 前景一屏展示网站
  • 电子商务网站建设程序应用题怎么做好seo推广
  • 公司网站建设费入账嘉兴港区规划建设门户网站
  • 北京微信网站制作做计算机题目的网站
  • 外贸网站建设报价杭州网络推广有限公司
  • 免费企业网络推广网站物流公司网页设计
  • 怎么查网站是哪家公司做的网站文章超链接怎么做
  • 松江泖港网站建设山西营销型网站联系方式
  • 北京时间网站建设专业的网站开发公司
  • 建站工具免费想做网络营销推广
  • 乐都企业网站建设哪家好高端网页设计培训学校
  • 网站和app可以做充值余额功能西安网站维护兼职
  • 免费的在线设计网站泉州网站建设推广服务
  • 建网站免费空间我自己做网站
  • 成都网站建设学习嘉兴企业网络营销推广平台
  • 网站ui界面设计软件江苏泰州海陵区建设局网站
  • 网站地图对网站有什么意义厦门知名做企业网站设计的公司
  • 河北省建设工程招标投标网站网站建设的建议例子
  • 柳州网站制作公司飞凡网站建设
  • 代理网站备案2345网址导航怎么彻底删掉
  • 沧州网站的公众号网站设计的企业
  • 简单的网站怎么做朋友圈软文范例
  • 网站建设费入什么科目2018网站开发税率多少钱
  • 太原网站科技公司备案中心查网站
  • 网站制作公司代理php是前端还是后端
  • 好看动漫网替代网站淘宝店
  • 网站开发一个页面多少钱企业文化学习心得