#Problem with multi module spring project

5 messages · Page 1 of 1 (latest)

kind pagoda
#

Hi! I had created multi module project with one main module pasteservice and two below: first paste-core where is main application located and second one paste-authorization (code below), I received errors while running application:

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of constructor in com.eripe14.pasteauthorization.user.UserService required a bean of type 'com.eripe14.pasteauthorization.user.UserRepository' that could not be found.


Action:

Consider defining a bean of type 'com.eripe14.pasteauthorization.user.UserRepository' in your configuration

classes from paste-authorization module:

@Repository
public interface UserRepository extends JpaRepository<User, Long> {

    Optional<User> findByUsername(String username);

    List<User> findAllUsers();

}
@Service
public class UserService implements UserDetailsService {

    private final UserRepository userRepository;

    @Autowired
    public UserService(UserRepository userRepository) {
        this.userRepository = userRepository;
    }

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        return this.userRepository.findByUsername(username).orElseThrow();
    }

    @Transactional
    public void save(User user) {
        this.userRepository.save(user);
    }

    @Transactional
    public List<User> findAllUsers() {
        return this.userRepository.findAllUsers();
    }

}

main class:

@SpringBootApplication(scanBasePackages = {"com.eripe14.pasteservice", "com.eripe14.pasteauthorization"})
public class PasteApplication {

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

}

can someone help me please, I'm new at spring I don't know what is happening there

pearl oxideBOT
#

This post has been reserved for your question.

Hey @kind pagoda! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

kind pagoda
#

my project structure