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

怎么做找券网站成都网站建设kaituozu

怎么做找券网站,成都网站建设kaituozu,wordpress系统密码忘记,萝卜建站appspringboot提供了两种配置信息的文件格式,application.properties和application.yml,基于直接明了,使用方便和高效的前提下下面的配置均采用yml格式配置, 注意 yml采用缩减方式来排列键后面紧跟冒号,然后空格&#x…

springboot提供了两种配置信息的文件格式,application.properties和application.yml,基于直接明了,使用方便和高效的前提下下面的配置均采用yml格式配置,

注意

  1. yml采用缩减方式来排列
  2. 键后面紧跟冒号,然后空格,最后是值
  3. 注意里面用到爱好数字的配置信息每个数组值前面的-(横杠)和值之间有一个空格

properties也yml/ymal相互转换

在线yaml转properties-在线properties转yaml-ToYaml.com在线yaml转properties工具 - toyamlicon-default.png?t=N7T8https://www.toyaml.com/

配置信息的分类(三种)

具体可以查看官网

Spring Boot Reference Documentationicon-default.png?t=N7T8https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#legal

springboot标准的配置

例如web服务的端口和上下文路径

server:port: 9999servlet:context-path: /yuanma

其他第三方配置信息

例如集成redis

spring:data:redis:host: "localhost"port: 6379database: 0username: "user"password: "secret"

自定义配置信息(两种获取信息的方式)

@Value+EL表达式

例如下面配置了邮件信息

#邮件信息
mail:from: 123@qq.comto: 456@qq.comserver: smtp.qq.comport: 8888

下面用@Value+EL表达式配置

package com.burns.yuanma.admin.pojo;import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;@Component
@Data
public class MailProperties {/*** 发件人*/@Value("${mail.from}")private String from;/*** 收件人*/@Value("${mail.to}")private String to;/*** 服务器地址*/@Value("${mail.server}")private String server;/*** 服务器端口号*/@Value("${mail.port}")private String port;
}

@ConfigurationProperties+prefix(前缀)

例如下面的用户信息配置,

#用户信息
user:address: 北京市朝阳区安外大羊坊八号院8号楼2单元112name: 张三age: 12sex: 男hobbies:- 足球- 游泳- 骑行- 篮球- 棒球

获取用户信息

package com.burns.yuanma.admin.pojo;import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;@Component
@ConfigurationProperties(prefix = "user")
@Data
public class UserProperties {/*** 姓名*/private String name;/*** 年齡*/private int age;/*** 性別*/private String sex;/*** 郵件*/private String email;/*** 住址*/private String address;/*** 愛好*/private String[] hobbies;
}

访问接口获取信息

上面两种方式都可以获取信息

下面是controller

package com.burns.yuanma.admin.controller;import com.burns.yuanma.admin.pojo.MailProperties;
import com.burns.yuanma.admin.pojo.UserProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
public class PropertiesController {@Autowiredprivate UserProperties userProperties;@Autowiredprivate MailProperties mailProperties;@RequestMapping("/userInfo")public String userInfo(){System.out.println(userProperties.toString());return userProperties.toString();}@RequestMapping("/mailInfo")public String mailInfo(){System.out.println(mailProperties.toString());return mailProperties.toString();}}

访问浏览器

 用户信息

http://localhost:9999/yuanma/userInfoicon-default.png?t=N7T8http://localhost:9999/yuanma/userInfo

 邮件信息

http://localhost:9999/yuanma/mailInfoicon-default.png?t=N7T8http://localhost:9999/yuanma/mailInfo

 

http://www.yayakq.cn/news/810416/

相关文章:

  • 西安做网站首选品牌网站建设坚持大蝌蚪
  • 建设部网站企业资质丹阳网站建设多少钱
  • 万盛网站制作山东聊城网站设计
  • 宜宾市规划建设局网站wordpress 搜索摘要
  • 域名交易asp.net 网站wordpress 仿站
  • 上海最专业的网站建设公司哪家好企业网站后端模板
  • 北京建网站的价格新手怎样自己做网站
  • 网站开发基础语言线上营销方式
  • 遵义网站建设公司怎么做网站跟域名
  • 学校网站建设联系电话在线推广企业网站的方法有
  • 制作网页网站教程网站建设书籍论文
  • 网页素材及网站架构制作环保设备网站源码
  • 抢注域名网站舆情监测软件价格
  • 安宁市建设厅网站php双语网站
  • 沃然建站平台官网温州气象权威发布
  • 重庆市招投标公共资源交易中心苏州网页优化服务
  • 搭建平台网站有什么用中国九江网官网
  • 营销型网站建设大千建站网站建设及推广外包
  • 怎么看网站有没有做301机关门户网站建设要求
  • 网站开发过程前端后端龙岗这边哪里有教做网站的
  • 现在的网站使用frameset做吗用什么做网站原型图
  • 签名能留链接的网站湖南省建设厅建筑业信息网官网
  • 体育 网站建设询价函格式计算机培训线上一对一
  • 保定网站建设多少钱哪家好社区推广
  • 乒乓球网站建设目标wordpress主题设置插件
  • 做网站的去哪找私活导航网站帝国cms模版
  • 建立网站的基本流程有哪些步骤毕设网站建设论文
  • 铜陵高端网站建设模板王字库官方下载
  • 中国建设企业协会网站北京十大必逛的商场
  • 网站备案相机营销型网站建设是什么