1

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 FailureAnalyzers 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
lebowski
  • 1,031
  • 2
  • 20
  • 37
  • Those are registered by default why would you need to register them manually?! You only need to register your own custom analyzers NOT the default ones. – M. Deinum Feb 05 '18 at 07:42
  • Is META-INF folder under resources? See https://stackoverflow.com/questions/17531625/how-to-include-a-config-file-in-the-meta-inf-services-folder-of-a-jar-using-ma – Adisesha Feb 05 '18 at 08:06
  • There is no need to do that, Spring Boot itself does provide them already. It would help if you'd describe what you're actually trying to do. – Stephane Nicoll Feb 05 '18 at 08:27
  • @StephaneNicoll i created spring boot gradle project using spring initializer. But i don't see `spring.factories` anywhere in my project. Just wondering where it is located – user9735824 Oct 15 '18 at 21:07
  • 1
    You don't need a `spring.factories` there. Please do not comment on unrelated issue and create your own with more details – Stephane Nicoll Oct 15 '18 at 21:24

1 Answers1

1

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.

paul-shuvo
  • 1,874
  • 4
  • 33
  • 37