java-totp icon indicating copy to clipboard operation
java-totp copied to clipboard

Fixed: Beans declared in TotpAutoConfiguration file are not created with Spring boot 3.2.1.

Open vinap opened this issue 2 years ago • 3 comments

Error: Beans declared in TotpAutoConfiguration.java file are not created after with Spring 3.2.1.its throwing below error image ''

Cause: The spring.factory file is deprecated in spring boot 2.7 and its completely removed in spring 3.2.1.

Fix: added dev.samstevens.totp.spring.autoconfigure.TotpAutoConfiguration entry in file totp-spring-boot-starter/src/main/resources/META-INF/org.springframework.boot.autoconfigure.AutoConfiguration

Reference from spring doc:- https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#auto-configuration-files

Spring Boot 2.7 introduced a new META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports file for registering auto-configurations, while maintaining backwards compatibility with registration in spring.factories. With this release, support for registering auto-configurations in spring.factories using the org.springframework.boot.autoconfigure.EnableAutoConfiguration key has been removed in favor of the imports file. Other entries in spring.factories under other keys are unaffected.

https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.7-Release-Notes#auto-configuration-registration

Auto-configuration Registration If you have created your own auto-configurations, you should move the registration from spring.factories under the org.springframework.boot.autoconfigure.EnableAutoConfiguration key to a new file named META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports. Rather than a single comma-separate list, each line contains the fully qualified name of an auto-configuration class. See the included auto-configurations for an example. For backwards compatibility, entries in spring.factories will still be honored.

vinap avatar Jan 01 '24 13:01 vinap

Shouldn't the filename be org.springframework.boot.autoconfigure.AutoConfiguration.imports?

eastack avatar Jul 10 '24 09:07 eastack

Is this project still maintained?

Duncol avatar Jul 25 '24 09:07 Duncol

If you are still using this library, and dont want to modify the sources you can explicitly import it in your SpringBootApplication class:

@SpringBootApplication
@ImportAutoConfiguration(TotpAutoConfiguration.class) // Manually register the auto-config
public class MyApplication {
    public static void main(String[] args) {
        SpringApplication.run(MyApplication.class, args);
    }
}

kiralyzoltan98 avatar Mar 03 '25 14:03 kiralyzoltan98