I have two Maven modules. The first, called the "application", contains the spring bootApplication class , which contains only these lines:
package org.example.application;
@SpringBootApplication
@ComponentScan({"org.example.model", "org.example"})
public class Application {
public static void main(String[] args) {
ApplicationContext ctx = SpringApplication.run(Application.class, args);
}
}
In the same Maven module and package org.example.application, I have RestControllerone that uses Component, which in turn uses the components of another Maven module, described below.
Another Maven module, called a "model", contains components spring boot(crud-repositories, entity, etc.). All these classes are in the same package structure as the first Maven ( org.example) module , but in subpackages of this, for example org.example.model.entities, org.example.model.repositoriesetc.
So the stream looks like this:
Maven module applicationin org.example package:
SpringBootApplication -> RestController -> MyComponent
, MyComponent, model Maven org.example.model.
, :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field myRepository in org.example.MyComponent required a bean of type 'org.example.model.repositories.MyRepository' that could not be found.
Action:
Consider defining a bean of type 'org.example.model.repositories.MyRepository' in your configuration.
org.example.model.repositories.MyRepository Maven, SpringBootApplication!
, :
@ComponentScan({"org.example.model", "org.example"}), , , .
?