Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot Autowiring From Another Module

Tags:

I am trying to establish connection between 3 modules in my project. When I try to reach my object with @Autowired error shows up. I'll explain my scenario a little bit.

MODULES

enter image description here

All of these modules have been connected inside of pom.xml. Lets talk about my problem.

C -> ROUTE.JAVA

.
.
.
@Autowired
public CommuniticationRepository;

@Autowired
public Core core;
.
.
.

B -> CORE

public class Core {
    private int id;
    private String name;
    private Date date;

    public Core(int id, String name, Date date) {
        this.id = id;
        this.name = name;
        this.date = date;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }
}

ERROR

Field communicationRepositoryin com.demo.xyz.A.RestControllers.Route required a bean of type 'com.demo.xyz.A.CommunicationRepository' that could not be found.

Action:

Consider defining a bean of type 'com.demo.xyz.A.CommunicationRepository' in your configuration.

A - > REPOSITORY.JAVA

@Component
@Repository
public interface CommunicationRepository extends CrudRepository<Communication, Date> {

    List<Communication> findByDate(Date date);

    void countByDate(Date date);
}