设置YML文件的引入

YML文件是,可以百度。

我现在只会用JSON转XML,所以查询了下:获取链接 https://www.site24x7.com/zhcn/tools/xml-to-yaml.html

这个链接 可以直接将XML文件转换成YML格式。

http://beautifytools.com/xml-to-yaml-converter.php

完成后,直接将内容到复制到vscode新建文件内,保存为yml格式。

打开IIS,配置一个网站,直接指向保存的文件。

打开链接,结果报404......

查了下,原来需要配置MIME类型,

看了下 xml格式对应的MIME为     .xml     text/xml

果断添加yml的MIME为                .yml    text/yml

好啦,浏览器打开链接    127.0.0.1/allfile/temp.yml    成功读取文件

转载于:https://my.oschina.net/qingqingdego/blog/3006858

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在Spring Boot应用程序中,可以使用 `application.yml` 或 `application.properties` 文件来配置应用程序属性。如果您正在使用 `application.yml` 文件,您可以使用 `@PropertySource` 注释和 `@ConfigurationProperties` 注释来从 `application.yml` 文件中加载属性。 以下是将 `application.yml` 文件中的属性加载到 Spring Boot 应用程序中的示例: 1. 在 `application.yml` 文件设置您的属性: ``` myproperty: name: "my name" age: 25 ``` 2. 创建一个类来保存您的属性: ``` @Component @ConfigurationProperties(prefix = "myproperty") public class MyProperty { private String name; private int age; // getters and setters } ``` 3. 在您的应用程序中使用 MyProperty 类: ``` @RestController public class MyController { @Autowired private MyProperty myProperty; @GetMapping("/myproperty") public String getMyProperty() { return "Name: " + myProperty.getName() + ", Age: " + myProperty.getAge(); } } ``` 在上面的示例中,`@ConfigurationProperties` 注释设置了属性的前缀,因此 Spring Boot 将自动从 `application.yml` 文件中加载属性。在 `MyController` 中,我们将 `MyProperty` 类注入并使用其中的属性。 注意事项:如果您使用的是 `application.properties` 文件,则需要将 `@PropertySource` 注释添加到您的类中,并指定属性文件的位置。例如: ``` @Component @PropertySource("classpath:myproperties.properties") @ConfigurationProperties(prefix = "myproperty") public class MyProperty { // ... } ``` 其中,`classpath:myproperties.properties` 是 `application.properties` 文件的位置。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值