Issue
I've read that I should not open an issue on github so I ask here. I've digged into the code and for example spring-boot-actuator-autoconfigure
doesn't define the @Configuration\@AutoConfiguration
classes inside META-INF/spring.factories
follow the content of the file:
org.springframework.boot.diagnostics.FailureAnalyzer=\
org.springframework.boot.actuate.autoconfigure.metrics.ValidationFailureAnalyzer
I've checked and ValidationFailureAnalyzer
is not even annotated with @Configuration\@AutoConfiguration
. Then I see the file META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
declaring all the classes @AutoConfiguration
follow a little extraction of the file:
org.springframework.boot.actuate.autoconfigure.amqp.RabbitHealthContributorAutoConfiguration
org.springframework.boot.actuate.autoconfigure.audit.AuditAutoConfiguration
org.springframework.boot.actuate.autoconfigure.audit.AuditEventsEndpointAutoConfiguration
org.springframework.boot.actuate.autoconfigure.availability.AvailabilityHealthContributorAutoConfiguration
...
all these classes are annotated with @AutoConfiguration
. So far so good If we read the docs they say that:
Spring Boot checks for the presence of a META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports file within your published jar.
Indeed if we import:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>2.7.3</version>
</dependency>
everything works just fine. I'm not skilled with gradle but I don't see any special dependecy in spring-boot-actuator-starter
or spring-boot-actuator-autoconfigure
.
Searching on google I've found a discussion here where they say:
In Spring Boot v. 2.7 auto-configuration registration is moved from spring.factories to a new file named META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports. Each line contains the fully qualified name of the auto-configuration. For backwards compatibility, entries in spring.factories will still be honored.
But honestly I've tryed to move the configuration classes in the new file but the configuration class is not loaded. I've writed an example here.
My org.springframework.boot.autoconfigure.AutoConfiguration.imports
file:
com.example.springbootstarterexample.configuration.Config
If I move to the old configuration spring.factries
everything works fine.
My @AutoConfiguration
class:
@AutoConfiguration(after = JpaRepositoriesAutoConfiguration.class)
//@AutoConfigureAfter(JpaRepositoriesAutoConfiguration.class)
@EnableJpaRepositories(basePackages = "com.example.springbootstarterexample.repository")
@Import({SomeServiceImpl.class, SomeEntityController.class})
public class ExampleAutoConfiguration {
}
am I doing something wrong? why the spring-boot-starter-actuator
works and my spring-boot-starter-example
dosn't?
Solution
Your file is called org.springframework.boot.autoconfigure.AutoConfiguration.import
,
and must be org.springframework.boot.autoconfigure.AutoConfiguration.imports
(notice the extra s
) at the end.
Answered By - Eugene
Answer Checked By - Marie Seifert (JavaFixing Admin)