简体   繁体   English

使用配置服务器解析Springboot应用程序中的占位符时出错

[英]Error resolving placeholders in springboot application with config server

I am configuring config server to use in a springboot application The application has recently been migrated from spring to springboot so most of the properties are used in applicationContext.xml files 我正在配置配置服务器以在springboot应用程序中使用该应用程序最近已从spring迁移到springboot,因此大多数属性都在applicationContext.xml文件中使用

Example : 范例:

<bean id="rabbitConnectionFactory"  class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory">      
    <property name="address" value="${rabbitmq.address}"/>
</bean>

This throw an IllegalArgumentException : Could not resolve placeholder 抛出IllegalArgumentException:无法解析占位符

I also have my configuration Properties file to load some properties by prefix, and I can use my properties if I declare them in the class below: 我也有配置属性文件,可按前缀加载某些属性,如果我在下面的类中声明了这些属性,则可以使用它们:

@Configuration
@ConfigurationProperties
public class ConfiguationProperties {}

But I don't want to put all the properties in the configuration properties file and keep my applicationContext directly loading properties using placeholders syntax, is there a possibility? 但是我不想将所有属性都放在配置属性文件中,并保持我的applicationContext使用占位符语法直接加载属性,有没有可能?

My error was that the path to my configuration files was incorrect because my properties files were in a subdirectory of my config path ${config-path}/subdirectory/myapplication-dev.properties 我的错误是配置文件的路径不正确,因为属性文件位于配置路径$ {config-path} /subdirectory/myapplication-dev.properties的子目录中

i removed the subdirectory and it works fine. 我删除了子目录,它工作正常。 It seems that the config server load correctly the properties files in the classpath only if it respects the schema url : 似乎配置服务器只有遵守模式url才能正确加载类路径中的属性文件:

 http://localhost:8888/${my-profile}/myapplication

and not : 并不是 :

http://localhost:8888/subdirectory/${my-profile}/myapplication

(event if i can see my properties in the web browser with this url) (如果我可以使用此URL在网络浏览器中看到我的属性,则为事件)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SpringBoot Starter Project-错误解决模板 - SpringBoot Starter Project - Error resolving template 在 TomEE 7.1.0 服务器上部署 Java 11 SpringBoot 应用程序错误 - Java 11 SpringBoot Application Error When Deployed on TomEE 7.1.0 Server 应用程序编译时出现springboot错误 - springboot error on the application compile 在Spring MVC 3.2.8中解析占位符 - Resolving placeholders in Spring MVC 3.2.8 将 WireMock Server 作为 SpringBoot 应用程序运行 - Run WireMock Server as a SpringBoot application Springboot Config 服务器客户端返回状态码:-1 - Springboot Config server client returns status code: -1 部署 Springboot Web 服务 Heroku。 配置 Dyno 形成时出现错误 [无法访问 jarfile server.port] - Deploy Springboot Webserivce Heroku. ERROR [Unable to access jarfile server.port] when config Dyno formation Springboot-Spring云配置服务器错误:org.springframework.boot.actuate.autoconfigure.TraceWebFilterAutoConfiguration.webRequestLoggingFilte - Springboot - Spring cloud config server error: org.springframework.boot.actuate.autoconfigure.TraceWebFilterAutoConfiguration.webRequestLoggingFilte spring.cloud.config.server.native.search-locations 不适用于 Spring 云配置服务器中的占位符 - spring.cloud.config.server.native.search-locations does not work with placeholders in Spring Cloud Config server SpringBoot Thymeleaf无法解析模板 - SpringBoot Thymeleaf Not Resolving Template
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM