[英]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.