java -- @WebFilter invalidation problem

background:

        The global log id was configured before. For details, please refer to java -- Configuring the global log id_java global log_Xiaobai's blog on the road to coding bugs-CSDN blog

        Later development found that the global ID was missing when printing the log, and it was empty when querying the log elk, as shown in the figure.

        I used the @WebFilter annotation to configure the filter, and the startup class used the @ServletComponentScan annotation to load the filter configuration class to implement the global log id.

reason:

        It turns out that when the code was being compiled later, the configuration file was placed separately in the common directory, which was different from the directory where the startup class was located, so the log filter could not be loaded.

solve:

        The @ServletComponentScan annotation specifies the directory where the log filter code is located and loads the file.


/**
 * 数据模块
 * 
 * @author ruoyi
 */
@EnableCustomConfig
@EnableCustomSwagger2
@EnableRyFeignClients
@ServletComponentScan("com.config.common.**")
@SpringBootApplication
@MapperScan({"com.assist.check.**.mapper","com.dw.**.mapper"})
public class DataWarehouseApplication
{
    public static void main(String[] args)
    {
        SpringApplication.run(DataWarehouseApplication.class, args);
    }
}

result:

        problem solved

 

Guess you like

Origin blog.csdn.net/DGH2430284817/article/details/131086827