Stack Exchange
Error init SpringBoot v.2.1.10.RELEASE app Parameter 0 of constructor
I have a SpringBoot app with this config file:
package com.bonanza.web.config;
    @Configuration
    @EnableJpaRepositories(basePackages = "com.bonanza.backend.repository")
    @EntityScan(basePackages = "com.bonanza.backend")
    @EnableTransactionManagement
    @EnableCaching
    @PropertySource("file:///${user.home}/.bonanza/application-common.properties")
    public class BonanzaApplicationConfig {

    }

and this service:
package com.bonanza.backend.service;


    @Service
    @Transactional(
        readOnly = true
    )
    public class UserService {

        private final RoleRepository roleRepository;
        private final UserRepository userRepository;
        private final PasswordEncoder passwordEncoder;
        private final PasswordResetTokenRepository passwordResetTokenRepository;

        public UserService(RoleRepository roleRepository, UserRepository userRepository, PasswordEncoder passwordEncoder, PasswordResetTokenRepository passwordResetTokenRepository) {
            this.roleRepository = roleRepository;
            this.userRepository = userRepository;
            this.passwordEncoder = passwordEncoder;
            this.passwordResetTokenRepository = passwordResetTokenRepository;
        }
    ..
    }

and the main class:
package com.bonanza.web
    @SpringBootApplication
    public class BonanzaWebApplication {

        public static void main(String[] args) {
            SpringApplication.run(BonanzaWebApplication.class, args);
        }

    }

and this controller
package com.bonanza.web.controller;
        @Controller
        public class AppErrorController implements ErrorController {
        protected final UserService userService;
        ..

    public AppErrorController(UserService userService, ErrorAttributes errorAttributes, EmailService emailService) {
            super(userService);
            this.errorAttributes = errorAttributes;
            this.emailService = emailService;
        }
    ...
        }

but when I start the app. I have this error:
Description:

Parameter 0 of constructor in com.bonanza.web.controller.AppErrorController required a bean of type 'com.bonanza.backend.service.UserService' that could not be found.


Action:

Consider defining a bean of type 'com.bonanza.backend.service.UserService' in your configuration.


can you add the package statements for every class

@SpringBootApplication, Will only search the current package and all its sub packages for components/beans. Your UserService package
com.bonanza.backend.service

is not a subpackage of BonanzaWebApplication
com.bonanza.web

So you can use with all the packages that need to be Component Scan
@ComponentScan({"com.bonanza.web","com.bonanza.backend.service"})
@SpringBootApplication
public class BonanzaWebApplication {

    public static void main(String[] args) {
        SpringApplication.run(BonanzaWebApplication.class, args);
    }

}

You can also specify component scanning in @SpringBootApplication annotation it self 
@SpringBootApplication(scanBasePackages = {"com.bonanza.web","com.bonanza.backend.service"})

