Error creating bean with name 'movieController': Unsatisfied dependency expressed through field 'moviesService';

Hello team,

I have installed all the right jdk and maven, but still getting the error “Error creating bean with name ‘movieController’: Unsatisfied dependency expressed through field ‘moviesService’; …”

Any advice?

Thanks,
Raj

Hi @Rajendra_91044,

Can you tell us what command are you running and the full stack trace that you are getting ?

When I try to run application.main, ie when I click “Run ‘as Application.main()’” , if throws the error “Error creating bean with name ‘movieController’: Unsatisfied dependency expressed through field ‘moviesService’; …”

Very frustrated…

Thanks,
Rajendra

Hi all team:
When I try to run application.main, ie when I click “Run ‘as Application.main()’” , also emite error , but my error is
(Application.java:10) and (MongoDBConfiguration.java:25), but I see that not exist error of compilation.
¿What is happening?

Help please:tired_face:

The problem got solved after I started everything from scratch, thanks!

Hi Rajendra

Im getting same error while running application: Unsatisfied dependency expressed through field ‘moviesService’; …”

Could you please help me solve this.

Appriciated your help.

Thanks an regards,
Mohammed Shafi Shaik

@Mohammed_Shafi_68012,

Make sure to configure Intellij with maven and spring boot support.
Follow the instructions in the Project Setup lesson.

I am using eclipse. I get the same error. I have created and ran other Maven/SpringBoot Applications so pretty sure everything is set-up correctly I also can connect to the cluster from the common line and when I enter “show dbs”, I see sample_mflix

Here is the applications.properties file…
spring.mongodb.uri=mongodb+srv://mongodb+srv://m220student:m2220password@mflix-prbbd.mongodb.net/test?retryWrites=true&w=majority
spring.mongodb.database=sample_mflix

Here is the error…
Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
2019-09-20 10:12:52.199 ERROR 22030 — [ main] o.s.boot.SpringApplication : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘movieController’: Unsatisfied dependency expressed through field ‘moviesService’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘moviesService’: Unsatisfied dependency expressed through field ‘movieDao’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘movieDao’ defined in file [/Users/robloy/MongoUniversity/mflix-java/mflix/target/classes/mflix/api/daos/MovieDao.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘mongoClient’ defined in class path resource [mflix/config/MongoDBConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.mongodb.client.MongoClient]: Factory method ‘mongoClient’ threw exception; nested exception is java.lang.IllegalArgumentException: A connection string using the mongodb+srv protocol can notcontain a host name that specifies a port
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:587) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]