java build_error ai_generated true

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

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
0Evidence
2024-10-05First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
8+ active

Root Cause

Maven resource filtering is enabled, but the placeholder ${db.url} is not defined in any properties file or POM.

generic

中文

Maven 资源过滤已启用,但占位符 ${db.url} 未在任何属性文件或 POM 中定义。

Workarounds

  1. 95% success Define the property in pom.xml
    <properties><db.url>jdbc:mysql://localhost:3306/mydb</db.url></properties>
  2. 90% success 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>

Dead Ends

Common approaches that don't work:

  1. Disabling resource filtering entirely 70% fail

    Other placeholders may need filtering, and disabling it breaks them.

  2. Adding a random property with a different name 90% fail

    The placeholder must match exactly; a different name won't be resolved.