January 2018
Intermediate to advanced
414 pages
10h 29m
English
Let's go back to our service and remove the @Service annotation. If we try to run the application now we get an error:
Field exampleService in com.microservices.chapter2.FirstController required a bean of type 'com.microservices.chapter2.ServiceInterface' that could not be found.
Our controller requires a bean that does not exist, since this class is no longer a component, the component scan will not create a bean for it. We can modify our application class, that holds our Spring application context, to create the bean defining a function that returns a new instance.
package com.microservices.chapter2import org.springframework.beans.factory.annotation.Autowiredimport org.springframework.boot.autoconfigure.SpringBootApplication ...
Read now
Unlock full access