spring boot could not resolve placeholder in string value 问题解决方法
2017-09-28 16:03
1046 查看
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'hosts' in string value "${db.hosts}"问题的产生是由于有多个properties文件造成的,如果再第一个properties文件中没有找,就不认为没有了,不继续找下一个properties文件解决办法如下:方法 一、在Application中加入一个静态方法import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.ComponentScan;import org.springframework.context.annotation.Configuration;import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;import org.springframework.core.io.ClassPathResource;@Configuration@SpringBootApplication@ComponentScanpublic class TestApplication {public final static void main(String[] args) {SpringApplication.run(VfcadaptorApplication.class, args);}@Bean public static PropertySourcesPlaceholderConfigurer placeholderConfigurer() { PropertySourcesPlaceholderConfigurer c = new PropertySourcesPlaceholderConfigurer(); c.setIgnoreUnresolvablePlaceholders(true); return c; }}方法二、 统一为属性name加前缀
<span lang="EN-US" font-size:11.5pt;font-family:consolas;"="">app.datasource.foo.type=daffaDataSource
app.datasource.foo.status =30
那就需要在类文件上加注解@ConfigurationProperties("app.datasource.foo")@ConfigurationProperties("app.datasource.foo")Publicclass AA{PrivateString type;PrivateString status;...}
相关文章推荐
- 解决 IllegalArgumentException: Could not resolve placeholder in string value "${XXXXXX}"
- 解决 IllegalArgumentException: Could not resolve placeholder in string value "${XXXXXX}"
- 解决 Could not resolve placeholder 'some.var.name' in string value
- spring cloud config---Could not resolve placeholder 'foo' in string value "${foo}"
- spring错误<context:property-placeholder>:Could not resolve placeholder XXX in string value XXX
- 解决 IllegalArgumentException: Could not resolve placeholder in string value "${XXXXXX}"
- spring错误:<context:property-placeholder>:Could not resolve placeholder XXX in string value XXX
- Spring 出现Could not resolve placeholder问题的解决方法
- 启动错误:Could not resolve placeholder 'spring.datasource.url' in value "${spring.datasource.url}"
- Could not resolve placeholder 'redis.pool.maxTotal' in string value "${redis.pool.maxTotal}"
- Could not resolve placeholder '***' in string value "${****}"
- 关于Spring-mybatis项目报Could not resolve placeholder错误的解决方法
- Could not resolve placeholder 'jdbc.url' in string value "${jdbc.url}"
- Could not resolve placeholder 'jdbc.url' in string value "${jdbc.url}"
- Could not resolve placeholder 'driver' in string value "${driver}"
- Could not resolve placeholder 'driverClasss' in string value "${driverClasss}"
- Could not resolve placeholder 'redis.pool.maxTotal' in string value "${redis.pool.maxTotal}
- 关于Could not resolve placeholder 'foo' in value "${foo}"的问题
- Could not resolve placeholder 'master.jdbc.url' in string value "${master.jdbc.url}"
- Could not resolve placeholder 'mail.from' in string value "${mail.from}" 报错原因