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

电子商务网站建设需要的语言及特点6盐城企业做网站多少钱

电子商务网站建设需要的语言及特点6,盐城企业做网站多少钱,wordpress 采集,全网营销推广 好做吗前些天发现了一个巨牛的人工智能学习网站#xff0c;通俗易懂#xff0c;风趣幽默#xff0c;忍不住分享一下给大家。点击跳转到教程。 上一篇博客写了 如何在Spring Boot application中配置mail . 使用 Value 注解注入属性. 但 Spring Boot 提供了另一种方式 #xff0c;能… 前些天发现了一个巨牛的人工智能学习网站通俗易懂风趣幽默忍不住分享一下给大家。点击跳转到教程。 上一篇博客写了 如何在Spring Boot application中配置mail . 使用 Value 注解注入属性. 但 Spring Boot 提供了另一种方式 能够根据类型校验和管理application中的bean。 这里会介绍如何使用ConfigurationProperties。 继续使用mail做例子。配置放在mail.properties文件中。属性必须命名规范才能绑定成功。举例: 1 protocol and PROTOCOL will be bind to protocol field of a bean 2 smtp-auth , smtp_auth , smtpAuth will be bind to smtpAuth field of a bean 3 smtp.auth will be bind to … hmm to smtp.auth field of a bean! Spring Boot 使用一些松的规则来绑定属性到ConfigurationProperties bean 并且支持分层结构hierarchical structure。 开始创建一个ConfigurationProperties bean: ConfigurationProperties(locations classpath:mail.properties, ignoreUnknownFields false, prefix mail) // 前辍为mail public class MailProperties { public static class Smtp { private boolean auth; private boolean starttlsEnable; // ... getters and setters }NotBlank private String host;private int port; private String from; private String username;private String password; NotNull private Smtp smtp; // ... getters and setters }…从如下属性中创建 ( mail.properties ): mail.hostlocalhost mail.port25 mail.smtp.authfalse mail.smtp.starttls-enablefalse mail.frommelocalhost mail.username mail.password上例中我们用ConfigurationProperties注解就可以绑定属性了。ignoreUnknownFields false告诉Spring Boot在有属性不能匹配到声明的域的时候抛出异常。开发的时候很方便! prefix 用来选择哪个属性的prefix名字来绑定。 请注意setters 和 getters 需要在ConfigurationProperties bean中创建! 与Value注解相反 这带来了代码中的一些困扰 (特别是简单的业务中个人观点). OK但是我们需要用属性来配置 application. 有至少两种方式来创建ConfigurationProperties。即可以搭配Configuration 注解来提供 Beans 也可以单独使用并注入 Configuration bean。 方案1: Configuration ConfigurationProperties(locations classpath:mail.properties, prefix mail) public class MailConfiguration { public static class Smtp {private boolean auth;private boolean starttlsEnable;// ... getters and setters}NotBlank private String host; private int port;private String from; private String username;private String password; NotNull private Smtp smtp; // ... getters and setters Bean public JavaMailSender javaMailSender() {// omitted for readability} }方案2 我们和上面例子一样注解属性然后用 Spring的Autowire来注入 mail configuration bean: Configuration EnableConfigurationProperties(MailProperties.class)public class MailConfiguration { Autowired private MailProperties mailProperties; // mailProperties.getxxx得到配置中的值。Bean public JavaMailSender javaMailSender() {// omitted for readability}}请注意EnableConfigurationProperties注解。 这个注解告诉Spring Boot 使能支持ConfigurationProperties。如果不指定会看到如下异常: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [demo.mail.MailProperties] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {org.springframework.beans.factory.annotation.Autowired(requiredtrue)}注意: 还有其他办法 (Spring Boot 总是有其他办法!) 让ConfigurationProperties beans 被添加 – 用Configuration或者 Component注解, 这样就可以在 component scan时候被发现了。 总结 ConfigurationProperties很方便使用。 比用Value注解好吗? 在特定的方案中是的,这只是一个选择问题。 看下Spring Boot的文档有更多的关于 typesafe configuration 属性 作者crocodile_b 链接https://www.jianshu.com/p/df57fefe0ab7 來源简书
http://www.pierceye.com/news/218303/

相关文章:

  • 信用门户网站建设规范win7 iis 发布asp.net网站
  • 织梦网站添加视频教程如何套用wordpress的源码
  • 网站服务器模式wordpress安装后只有英文版
  • 企业网站建设晋升wordpress 自助建站
  • 网站建设案例建站资源
  • 四大商业网站镇江制作网站的
  • 做网站系统学校宠物交易网站模板
  • 佛山市官网网站建设哪家好瑶海合肥网站建设
  • 微网站app建筑图片大全高清
  • 贵阳金阳网站建设公司网站开发与维护书
  • 做非法网站判什么邢免抵退税在哪个网站做
  • 手机网站如何制作免费网站的内容和功能
  • 宁波网站推广合作商品牌设计包括
  • 辽宁省建设厅官方网站制作一个静态网站的步骤
  • 营销外贸网站建设北京房地产网站建设
  • 青海网站建设公司代理记账如何获取客户
  • 做视频必须知道的一些网站企业搜索
  • 网站定制开发北京淮南网新闻最新消息
  • 网站描述怎么写比较好企业信息系统案例
  • 青峰集团响应式网站功能性的网站归档系统
  • 龙岩招聘求职网站有哪些网站建设促销活动
  • 人力资源服务外包网站tdk优化文档
  • 做黑网站吗江苏建筑业网
  • 地区门户网站 wap appcdn接入wordpress出错
  • 网站建设为什么学flash最新新闻消息事件
  • 高端网站建设需要的人员配备编辑目录中的字体 wordpress
  • 电脑维修网站模板金融商城快捷申请网站模板下载
  • wordpress 本地建站教程化纤公司网站建设
  • 广州网站设计公司新闻给客户做非法网站
  • 微商城手机网站制作公司痞子 wordpress