Failed to load property source from 'file:/*****/target/classes/application.yml' (classpath:/application.yml)

  使用springboot默认创建项目,是application.properties,改成yml格式时,需要注意以下几点:

  • 注释中不能用中文
  • yml格式,采用tree形状,key和value中的“冒号",冒号与值之间要有空格,如 username: root
  • 同一级别节点格式要对齐,下面红包部分由于没有对齐,运行项目时报错

 

复制代码
spring:
  datasource:
    url: jdbc:mysql://127.0.0.1:3306/business?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
    username: root
     password: root
    driverClassName: com.mysql.cj.jdbc.Driver
    # use mysql
  jpa:
    database: mysql
      # is show  sql
    show-sql: true
mybatis:
  typeAliasesPackage: com.xj.demo.model
  mapper-locations: classpath:mapper/*.xml
# JWT Object save audience
audience:
    clientId: 098f6bcd4621d373cade4e832627b4f6
    # A key that can be replaced by Base64 encryption
    base64Secret: MDk4ZjZiY2Q0NjIxZDM3M2NhZGU0ZTgzMjYyN2I0ZjY=
    # The issuing subject of the JWT shall be deposited in the issuer
    name: springbootapi
    # Expired 24 hours
    expiresSecond: 86400

pagehelper:
    helperDialect: mysql
    reasonable: true  # To minimize or maximize the number of pages when the input page is negative or larger
    supportMethodsArguments: true
    params: count:countSql
复制代码

 

  yml中格式错误,肉眼不太容易找出错误,推荐一个在线查看的工具:http://old.qqe2.com/jsontool/yaml.php

  修改正确后的效果

posted @   低调码农哥!  阅读(1398)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示