Springboot service scanning introduces components such as services of jar packages

1. Current Springboot project configuration

1. Add the annotation @ComponentScan(value="com") to the Application startup class

The following code is configured to scan files under wms and common services. common is a public service jar package introduced by wms (including components such as database connection pool, controller, service, mapper, and bean, and these components cannot be named the same as those currently served by wms ) .

@ComponentScan(basePackages = {"com.westernpost.wms","com.westernpost.common"})

After adding the annotation, spring will only scan the package configured by the annotation, and will no longer automatically scan the files under the package and sub-package where the startup class is located.

Note: The path scanned by springboot by default is all files under the package where the application startup class of the project is located and all subpackages.

2. The current service normally uses annotations to call the components of the jar package.

2. Introduce the configuration of the jar package service

This public project can be a complete springboot service that can be started and accessed normally. The pom configuration is uploaded to the Nexus private server for normal introduction of business services. It is best to make it a portable API service.

Guess you like

Origin blog.csdn.net/MingDaw/article/details/127810564