spring boot could not resolve placeholder in string value 问题解决方法
来源:互联网 发布:linux安装tgz文件 编辑:程序博客网 时间:2024/05/21 05:17
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
@ComponentScan
public 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;
...
}
- spring boot could not resolve placeholder in string value 问题解决方法
- $Value{}ntException: Could not resolve placeholder 'KEY' in string value "${
- Could not resolve placeholder 'spring.security.mapping.directory' in string value "${spring.security
- Could not resolve placeholder 'driverClassName' in string value "${driverClassName}"
- Could not resolve placeholder 'CUST_INDUSTORY' in string value "${CUST_INDUSTORY}"
- Could not resolve placeholder 'driver' in string value "${driver}"
- 解决 IllegalArgumentException: Could not resolve placeholder in string value "${XXXXXX}"
- Could not resolve placeholder 'driverClasss' in string value "${driverClasss}"
- 解决 IllegalArgumentException: Could not resolve placeholder in string value "${XXXXXX}"
- spring cloud config---Could not resolve placeholder 'foo' in string value "${foo}"
- Could not resolve placeholder 'jdbc.driverClassName' in string value "${jdbc.driverClassName}
- Could not resolve placeholder 'master.jdbc.url' in string value "${master.jdbc.url}"
- 解决 Could not resolve placeholder 'some.var.name' in string value
- Could not resolve placeholder 'jdbc.username' in string value "${jdbc.username}"
- Could not resolve placeholder 'jdbc.url' in string value "${jdbc.url}"
- 报错Could not resolve placeholder 'jdbc.driverClassName' in string value "${jdbc.driverClassName}
- Could not resolve placeholder 'redis.pool.maxTotal' in string value "${redis.pool.maxTotal}"
- Could not resolve placeholder 'jdbc.driverClassName' in string value "${jdbc.driverClassName}错误
- 通过自己编写的C语言程序获取lcm正常格式的初始化数据代码
- 人脸检测和识别及python实现系列(1)-- 环境配置和相关类库安装
- 牛客网--2016--美团奇数位丢失
- 671
- vue基础知识
- spring boot could not resolve placeholder in string value 问题解决方法
- 使用rdo配置answer.ini网桥,实现创建能与外网通信的网络
- Android开发之Tween(补间动画)
- Android 进程间通信 Messenger
- linux服务监测 自动启动
- SwitchHosts—hosts管理利器
- swift中的!和?作用
- 什么样的Web开发框架才是好的前端框架
- 剑指offer——59.按之字形顺序打印二叉树