Springboot introduces a custom jar package and can't find the bean?

tips:

The /META-INF/spring.factories file is deprecated in Spring Boot 2.7, and support for /META-INF/spring.factories will be removed in Spring Boot 3.

The new way of writing is to create a new file:

/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

The content can be directly placed in the configuration class (note that there is a spring directory),
such as this: com.github.cherryNo1.ActuatorConfig
If the springboot version is higher than 2.7, switch to the new writing method and try
insert image description here
Spring Boot 3. Please use /META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.importsit to directly write what needs to be added to the container Beans
insert image description here
use this class to add scan packages

package com.github.cherryNo1;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
/**
 * @author maqingbo
 */
@Configuration
@ComponentScan(basePackages = {
    
    "com.github.cherryNo1"})
public class ActuatorConfig {
    
    
}

Below Spring Boot 3 please use/META-INF/spring.factories

insert image description here

Guess you like

Origin blog.csdn.net/weixin_47287832/article/details/129639852