Can the classes in the jar package in Spring be on autowire?

problem description

under the springboot environment, some classes in the jar package can be automatically assembled, while others can not. What"s going on?

Jan.08,2022

SpringBoot defaults to injecting all the classes that need to be injected under the root package of the startup class. If you need to inject other package path types, you need to add some attributes scanBasePackages = {"com.package1", "com.package2"}

to the @ SpringBootApplication annotation in the startup class.
@SpringBootApplication(scanBasePackages = {"com.package1", "com.package2"})
public class ApplicationRun {
    public static void main(String[] args) {
        SpringApplication.run(ApplicationRun.class, args);
    }
}

attribute scanBasePackages fill in the path of the package you need to inject


RestTemplate requires @ Bean,
https://www.baeldung.com/rest.
Don't feel that everything is in spring. Some things just need to be injected by yourself

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4625e-44b9d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4625e-44b9d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?