After looking at the Github, the main reason for your initial error is that the class marked with @SpringBootApplication
is inside another package as the rest of the configuration classes.
By default, Spring Boot scans for packages starting with the package that the @SpringBootApplication annotated class is in, and also sub-packages in that folder. The app isn't aware of the classes in com.haharr.security
package.
And that is also the reason why it works when you define UserDetailsService inside the Main class annotated with @SpringBootApplication
. The rest of classes in other packages are in fact ignored and the app works thanks to autoconfigurations.
Although the app can be configured to look for components in other places, I strongly suggest to follow the best practices and move the AuthorizationServerApplication
one package (folder) up, in com.haharr
pacakage (from com.haharr.authorizationserver
package).
After that, another whole set of problems to be solved, but that is food for another thread and most likely the tutorials can help with them.