It is neat to have configuration classes in a /config folder, located at the same level as the main class:
package com.leibnix.configs;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
// org.lala.capuccino is in a external library
@Configuration
@ComponentScan(basePackages = {"org.lala.capuccino"})
public class ConfigLibraries {
}
note that the packages:
com.leibnix
and
org.lala.capuccino
they are different
The main class must have a SpringBoot annotation to scan child packages of “com.leibnix”
@SpringBootApplication
public class MyApplication {
The main class is in the “com.leibnix” package and scans all components that have the “com.leibnix” prefix in their package.
A package that does not have a “com.leibnix” prefix will not be scanned.
the imports:
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
the dependency is:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>