Could not resolve placeholder 'IMAGE_SERVER_URL' in value "${IMAGE_SERVER_URL}"
时间: 2024-04-25 21:22:15 浏览: 181
根据提供的引用内容,问题是在启动后报错"Could not resolve placeholder 'IMAGE_SERVER_URL' in value "${IMAGE_SERVER_URL}"。这个错误是因为无法解析占位符'IMAGE_SERVER_URL'的值。根据引用\[1\]中的代码,这个占位符应该在配置文件application.properties中被定义了。解决这个问题有两种方法。
解决方法一是在pom.xml中添加resource标签,以便能够解析配置文件。具体的配置如下:
```xml
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.yml</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.yml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
```
这样配置文件就能被正确解析了。\[3\]
解决方法二是在启动类中将PropertySourcesPlaceholderConfigurer放到IOC容器中。具体的代码如下:
```java
@Bean
public static PropertySourcesPlaceholderConfigurer placeholderConfigurer() {
PropertySourcesPlaceholderConfigurer c = new PropertySourcesPlaceholderConfigurer();
c.setIgnoreUnresolvablePlaceholders(true);
return c;
}
```
这样配置文件中的占位符就能被正确解析了。\[2\]
希望以上解决方法能够帮助您解决问题。
#### 引用[.reference_title]
- *1* [spring boot 报错 Could not resolve placeholder ‘xxx‘ in string value “${xxx}](https://blog.csdn.net/Zoooozz/article/details/114685157)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* *3* [Could not resolve placeholder ‘XXX‘ in string value “${XXX}](https://blog.csdn.net/weixin_53233296/article/details/129459868)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文