Error creating bean with name: Injection of autowired dependencies failed, could not resolve placeholder

We Are Going To Discuss About Error creating bean with name: Injection of autowired dependencies failed, could not resolve placeholder. So lets Start this Java Article.

Error creating bean with name: Injection of autowired dependencies failed, could not resolve placeholder

  1. Error creating bean with name: Injection of autowired dependencies failed, could not resolve placeholder

    have you tried to rename your 'app.properties' file 'application.properties'?
    What is the path of this file ? It has to be under 'resources' directory if you don't want to manually configure its path.

  2. Error creating bean with name: Injection of autowired dependencies failed, could not resolve placeholder

    have you tried to rename your 'app.properties' file 'application.properties'?
    What is the path of this file ? It has to be under 'resources' directory if you don't want to manually configure its path.

Solution 1

have you tried to rename your ‘app.properties’ file ‘application.properties’?
What is the path of this file ? It has to be under ‘resources’ directory if you don’t want to manually configure its path.

Original Author nicolas Of This Content

Solution 2

Make sure your properties file resides in resources and you’re copying it during compilation.

Also, the name needs to be application.properties or application-{profile}.properties. Read this for more info.

Configuration | Spring Framework Docs

If not, you can use @PropertySource to specify properties file if you’re not naming it as per convention or external configurations.

PropertySource | Spring Framework Docs

Property Source Example | Mkyong

Original Author Dhruvil Vaghela Of This Content

Solution 3

I had app.properties and application.properties, I gathered these two files in application.properties and deleted the other but it does not change anything. The file is in “resources” directory and seems to be recognized by Intellij.

resources directory

I added this in the pom.xml

<build>
    <resources>     
        <resource>
            <directory>src/main/resources</directory>
            <includes>                      
                <include>**/*.properties</include>                  
            </includes>
        </resource>            
    </resources>
</build>

and the following line in WebConfig but it is still the same.

@PropertySource("classpath:/application.properties")

The application I’m trying to run is a fork of an application that used exactly the same properties, and that runs well..

Original Author Dhruvil Vaghela Of This Content

Solution 4

Resolved it by adding this line in the pom

<filtering>true</filtering>

giving this

<build>
    <resources>     
        <resource>
            <filtering>true</filtering>
            <directory>src/main/resources</directory>
            <includes>                      
                <include>**/*.properties</include>                  
            </includes>
        </resource>            
    </resources>
</build>

Original Author Dhruvil Vaghela Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment