bootstrap.yml 未加载 Spring Boot 2

2024-01-21

我遇到了与此类似的问题thread https://stackoverflow.com/questions/48300174/my-application-does-not-read-bootstrap-yml-why-is-that(尚未解决)。

我有一个 Spring Boot 2 应用程序和一个 bootstrap.yml 文件。有一个属性“spring.data.cassandra.keyspace-name”未被拾取。我在 src/main/resources 下只有一个 bootstrap.yml 。

重要提示:如果我将 bootstrap.yml 重命名为 application.yml,一切都会正常运行。

这看起来像是一个真正的错误。有人可以确认他们也面临这个问题吗?或者我做错了什么?

bootstrap.yml的内容如下:

spring:
    profiles: default 
    # Pretty-print JSON responses
    jackson:
        serialization:
            indent-output: true
    data:
      cassandra:
        contact-points: localhost
        keyspace-name: samplekeyspace

我的 pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

<groupId>org.sample.org</groupId>
<artifactId>sample-data</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>cart-data</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.5.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.10</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-cassandra-reactive</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-webflux</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.projectreactor</groupId>
        <artifactId>reactor-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

我收到的错误是:

Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.data.cassandra.keyspace-name' in value "${spring.data.cassandra.keyspace-name}"
    at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:172) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:124) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:237) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:211) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.lambda$processProperties$0(PropertySourcesPlaceholderConfigurer.java:175) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveEmbeddedValue(AbstractBeanFactory.java:839) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1083) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1062) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:583) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:372) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1341) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:572) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]

仅当您使用任何 Spring Cloud Starter 模块时,才会使用 bootstrap.yml(或 .properties)文件。这用于指定 Spring Cloud 配置服务器位置,以引导最小应用程序上下文,该上下文将从配置服务器收集应用程序属性,然后使用这些属性创建一个子上下文以启动真正的应用程序。 如果您不使用 Spring Cloud 配置功能,则可以使用应用程序的 application.yml 或 .properties 文件。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

bootstrap.yml 未加载 Spring Boot 2 的相关文章

随机推荐

  • 释放R中的内存

    在 R 中 我尝试将几组时间序列数据组合并转换为 xtshttp www truefx com page downloads http www truefx com page downloads但是 这些文件很大并且有很多文件 因此这导致我
  • 正确记录日志

    所以我的问题是关于日志记录 以及如何处理可能影响您的代码和运行时行为的日志语句 日志文件 每个程序都应该编写这些文件以正确解决问题 但如何正确执行呢 大多数日志语句的获取成本非常高 因为它们应该提供有用的信息 并且即使完全禁用日志记录 它们
  • 了解 Lambda 闭包类型如何删除默认构造函数

    从5 1 2开始 19 与 lambda 表达式关联的闭包类型有一个已删除的 8 4 3 默认构造函数和一个被删除的 复制赋值运算符 它有一个隐式声明的复制构造函数 12 8 并且可能有一个隐式声明的 移动构造函数 12 8 注意 复制 移
  • '已溢出其堆栈”' aria-label='构造大树时“线程'
    '已溢出其堆栈”'> 构造大树时“线程'
    '已溢出其堆栈”

    我实现了一个树结构 use std collections VecDeque use std rc Rc Weak use std cell RefCell struct A children Option
  • 中心标签还有效吗?

    我主要使用 HTML
  • 切换/切换 div (jQuery)

    我希望完成一项相当简单的任务 我希望 我有两个 div 标签和一个锚标签 如下所示 a href forgot password a div div div style display none div 我希望使用锚标记在两个 div 标记
  • 如何使用终端运行特定的 Android 应用程序? [复制]

    这个问题在这里已经有答案了 我已经安装了 Eclipse 和 Android SDK 一切都运行良好 我想安装 apk 文件 因此我已按照说明进行操作 但问题是 当我启动模拟器时 它不会自动运行我的应用程序 终端中是否有命令允许我运行我要求
  • iOS 上 UIImage 的运动模糊效果

    有没有办法在 UIImage 上获得运动模糊效果 我尝试了 GPUImage Filtrr 和 iOS Core Image 但所有这些都有常规模糊 没有运动模糊 我也尝试过 UIImage DSP 但它的运动模糊几乎不可见 我需要更强大的
  • java.lang.IllegalArgumentException:尝试打开下载的图像时未知的 URI

    我无法打开下载的图像DownloadManager单击通知时 这就是它的可重现性 我使用从网络下载图像DownloadManager 然后 当我单击有关此下载的通知时 操作系统会显示一个对话框 我可以在其中选择应用程序来打开下载的图像 但是
  • ASP.NET MVC 路由, Html.BeginForm

    div div
  • innerHTML 返回 NaN 和文本

    我遇到一个问题 我尝试返回一个值innerHTML但我得到了一个 NaN 我知道我的变量不是数字 但为什么他一直告诉我这个 function checkWord id nameOutput var pattern new RegExp b
  • 是否可以在操作系统级别限制 php 可以通过 exec 传递哪些命令?

    我目前正在主持一个Drupal http drupal org CentOS 计算机上的 6 个站点 德鲁帕尔 CMS http en wikipedia org wiki Content management system 配置包含几十个
  • 在 C++ 中设置差异

    如果我知道一个集合是另一个集合的子集 并且我想找出差异 那么最有效的方法是什么 前任 伪代码 gt set
  • 对于生成 1..n 范围内的 N 个唯一随机数,以下哪种算法在性能和顺序方面更好?

    1 取一个包含 n 个元素的数组 1 2 3 n 使用任意随机洗牌数组的标准算法对数组进行洗牌 修改后的数组的前 N 个元素就是您要查找的内容 2 只需使用Random Next 循环并检查它是否已经存在于Dictionary 直到我们有
  • 未显示数据库中的 JSF bean

    我有以下豆 import java util List import javax faces bean RequestScoped import javax annotations ManagedBean import javax pers
  • 我怎样才能用承诺重写这个?

    我正在为 T 恤网站构建内容抓取器 目标是仅通过一个硬编码的 url 进入网站 http shirts4mike com 然后 我将找到每件 T 恤的所有产品页面 然后创建一个包含其详细信息的对象 然后将其添加到数组中 当数组填满 T 恤时
  • 关于图形工具中嵌套块模型的基本问题

    非常简短地提出两到三个基本问题minimize nested blockmodel dl https graph tool skewed de static doc inference html graph tool inference m
  • C# 的跨平台嵌入式数据库/键值存储 [关闭]

    Closed 此问题正在寻求书籍 工具 软件库等的推荐 不满足堆栈溢出指南 help closed questions 目前不接受答案 我正在寻找一种快速 可嵌入的键 值存储 其具有键集合上的游标语义 或简单的可嵌入数据库 可以在 NET
  • 小端和大端

    我必须编写一个例程来在两种表示形式之间进行转换 但我有点困惑 如果我有一个内存为 32 位字的架构 我必须存储字 0xA15D23B1 使用 Big endian 时 内存在 23 之后的 5D 之后变为 A1 最后变为 B1 使用 Lit
  • bootstrap.yml 未加载 Spring Boot 2

    我遇到了与此类似的问题thread https stackoverflow com questions 48300174 my application does not read bootstrap yml why is that 尚未解决