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

做设计需要素材的常用网站德州市住房建设局网站

做设计需要素材的常用网站,德州市住房建设局网站,旅游攻略那个网站做的好,承德信息港3.1 系统配置文件 3.1.1 application.properties SpringBoot支持两种不同格式的配置文件#xff0c;一种是Properties#xff0c;一种是YML。 SpringBoot默认使用application.properties作为系统配置文件#xff0c;项目创建成功后会默认在resources目录下生成applicatio…3.1 系统配置文件 3.1.1 application.properties SpringBoot支持两种不同格式的配置文件一种是Properties一种是YML。 SpringBoot默认使用application.properties作为系统配置文件项目创建成功后会默认在resources目录下生成application.properties文件。该文件包含SpringBoot项目的全局配置。 我们可以在application.properties文件中配置SpringBoot支持的所有配置项比如端口号、数据库连接、日志、启动图案等。 #服务器端口配置 server.port 8081 #thymeleaf 模板 spring.thymeleaf.prefixclasspath:/templates/ spring.thymeleaf.suffix.html spring.thymeleaf.modeHTML spring.thymeleaf.encodingUTF-8 spring.thymeleaf.servlet.content-typetext/html 以上示例将thymeleaf模板相关的配置放在一起清晰明了从而便于快速找到thymeleaf的所有配置。 3.修改默认配置文件名 new SpringApplicationBuilder(ApplicationDemo.class).properties(spring.config.locationclasspath:/application.propertie).run(args); 3.2 自定义配置项 3.2.2 Environment Autowired private Environment env; Test void getEnv(){ System.out.println(env.getProperty(com.weiz.costum.firstname)); System.out.println(env.getProperty(com.weiz.costum.secondname)); } 3.2.3 ConfigurationProperties 在实际项目开发中需要注入的配置项非常多时前面所讲的value和Environment两种方法就会比较繁琐。这时可以使用注解ConfigurationProperties将配置项与实体Bean关联起来实现配置项与实体类字段的关联读取配置文件数据。下面通过示例演示ConfigurationProperties注解如何读取配置文件。 1.创建自定义配置文件 在resources下创建自定义的website.properties配置文件示例代码如下: com.weiz.resource.nameweiz com.weiz.resource.websitewww.weiz.com com.weiz.resource.language.java 在上面的示例中创建了自定义的website.properties配置文件增加了name、website、language等三个配置项这些配置项的名称的前缀都是com.weiz.resource。 2.创建实体类 创建WebSiteProperties自定义配置对象类然后使用ConfigurationProperties注解将配置文件中的配置项注入到自定义配置对象类中示例代码如下: Configuration ConfigurationProperties(prefix com.weiz.resource) PropertySource(value classpath:website.properties) public class WebSiteProperties{ private String name; private String website; private String language; public String getName(){ return name; } public void setName(String name){ this.namename; }         public String getWebsite(){ return website; } public void setWebsite(String website){ this.websitewebsite; } public String getLanguage(){ return language; } public void setLanguage(String language){ this.languagelanguage; } } 从上面的示例代码可以看到我们使用了Configuration注解、ConfigurationProperties和PropertySource三个注解来定义WebSiteProperties实体类: 1)Configuration定义此类为配置类用于构建bean定义并初始化到Spring容器。 2)ConfigurationProperties(prefixcom.weiz.resource)绑定配置项其中prefix表示所绑定的配置项的前缀。 3)ProperSource(valueclasspath:website.properties)指定读取的配置文件及其路径。 PropertySource不支持引入YML文件。 通过上面的WebSiteProperties类即可读取全部对应的配置项。 3.调用配置项 使用配置实体类中的方式也非常简单只需将WebSiteProperties注入到需要使用的类中示例代码如下: Autowired private WebSiteProperties website; Test void getProperties(){ System.out.println(website.getName()); System.out.println(website.getWebsite()); System.out.println(website.getLanguage()); }
http://www.hkea.cn/news/14431295/

相关文章:

  • 怎么改版一个网站win7和WordPress的关系
  • 给女朋友做的网站内容广告设计软件哪个好
  • 青海省教育厅门户网站北京app外包公司哪家好
  • 衡水精品网站建设黑龙江建设部网站
  • 宜兴建设局网站拖拽式wordpress建站
  • 免费网站空间注册万户网站制作
  • 企业网站制作教程视频wordpress 您没有足够的权限
  • 中国咖啡网站建设方案wordpress厨房家居主题
  • 网站建设的栏目内容网页制作步骤图文
  • 网站关键词排名分析seo新站如何快速排名
  • 淘宝上做网站怎么样苏州高端网站定制
  • 无锡产品排名优化seo基础知识
  • g2g有哪些网站品牌网络授权书
  • 大连网站建设方案案例传媒公司vi
  • 注册德国网站域名网站建设与管理试卷 判断题
  • 网站欢迎框代码wordpress 开玩笑 呵
  • 数码产品简约大气网站设计临沂网站建设对实体企业的重要性
  • 汕尾东莞网站建设新乡手机网站建设哪家好
  • 电子商务网站制作教程WordPress随机句子
  • html5网站搭建企业网站不足
  • 做网站需要哪些工程师东莞网络推广怎么样
  • 网站如何带来流量做写手一般上什么网站
  • 在线简历免费制作网站58网站自己做
  • 网站设计项目明细网件路由器无线桥接
  • 整站优化多少钱软件研发租用网站怎么做分录
  • 湛江手机网站建设公司wordpress主题格式
  • 网站程序 wordpress 织梦 discuzwordpress 页面 置顶
  • 海拉尔网站建设 网站设计上海市工程建设质量管理协会网站
  • 做网站要多少钱怎么样wordpress开发小工具栏
  • 学网络营销好就业吗天津优化公司哪家好