Mohit224
Mohit224

Reputation: 493

Spring boot app in another project from controller class

I want to know if I can keep my Spring boot class in Project A and my controller and services in Project B and invoke the end-points from Project A? The reason to do this is because I want to give Project A (which has dependency of Project B) an option to extend my controller and services to override any method.

Upvotes: 0

Views: 2018

Answers (1)

Adina Rolea
Adina Rolea

Reputation: 2109

Yes, it is a common practice to have your starter in a project and the libraries in another (spring projects are a good example for it).

  1. it is better to have them separated in 2 repositories :faster build, version management, separation of responsibility between team members etc.

  2. Build the project with the libraries (A)

  3. Project with the starter (B) will have a dependency to project A

  4. In general, it is recommended to have a configuration in project A with @ComponentScan and project B should import the configuration.

If the beans are scanned from project A, you will have access to all endpoints and services.

Upvotes: 1

Related Questions