java
build_error
ai_generated
true
过滤资源 'src/main/resources/application.properties' 中的值 '${db.url}' 失败,项目 com.example:my-app:无法解析占位符 'db.url'。
Failed to filter resource 'src/main/resources/application.properties' with value '${db.url}' for project com.example:my-app: Could not resolve placeholder 'db.url' in value '${db.url}'
ID: java/maven-resource-filtering-error
80%修复率
85%置信度
0证据数
2024-10-05首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 8+ | active | — | — | — |
根因分析
Maven 资源过滤已启用,但占位符 ${db.url} 未在任何属性文件或 POM 中定义。
English
Maven resource filtering is enabled, but the placeholder ${db.url} is not defined in any properties file or POM.
解决方案
-
95% 成功率 Define the property in pom.xml
<properties><db.url>jdbc:mysql://localhost:3306/mydb</db.url></properties>
-
90% 成功率 Use a properties file with filtering enabled
Create src/main/filters/db.properties with db.url=jdbc:mysql://localhost:3306/mydb and add <filters><filter>src/main/filters/db.properties</filter></filters>
无效尝试
常见但无效的做法:
-
Disabling resource filtering entirely
70% 失败
Other placeholders may need filtering, and disabling it breaks them.
-
Adding a random property with a different name
90% 失败
The placeholder must match exactly; a different name won't be resolved.