简体   繁体   中英

META-INF/spring.factories file missing from Spring Boot application

I am fairly new to Spring and Spring Boot, and was asked to work on a legacy Spring Boot project. I am supposed to include in the project some FailureAnalyzer s provided by Spring Boot. According to tutorials I came across (like here ), all that needs to be done is registering the several FailureAnalyzer classes in the META-INF/spring.factories file.

But when I build the project (using Maven), I don't see a spring.factories file inside the target/META-INF directory. I tried adding one myself but it doesn't seem to be read by the project. What am I missing? What should I be doing to register these FailureAnalyzers?

In case you need it, the spring.factories file looks like this:

org.springframework.boot.diagnostics.FailureAnalyzer=\
  org.springframework.boot.diagnostics.analyzer.AbstractInjectionFailureAnalyzer,\
  org.springframework.boot.diagnostics.analyzer.BeanCurrentlyInCreationFailureAnalyzer,\
  org.springframework.boot.diagnostics.analyzer.BeanNotOfRequiredTypeFailureAnalyzer,\
  org.springframework.boot.diagnostics.analyzer.BindFailureAnalyzer,\
  org.springframework.boot.diagnostics.analyzer.ConnectorStartFailureAnalyzer,\
  org.springframework.boot.diagnostics.analyzer.NoUniqueBeanDefinitionFailureAnalyzer,\
  org.springframework.boot.diagnostics.analyzer.PortInUseFailureAnalyzer,\
  org.springframework.boot.diagnostics.analyzer.ValidationExceptionFailureAnalyzer

I think you have mistaken the location of spring.factories file. This file will not be present in the project resources folder. Go to Maven dependencies and look into each Jar META-INF file and you will find spring.factories file in most of the jars.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM