Home > Software design >  Can't use annotation from spring boot starter
Can't use annotation from spring boot starter

Time:12-29

I've made a spring boot starter with annotation class, bean post processor and config class. After mvn install I add this starter as a dependency to another project. Starter appears in external libs and IntelliJ can even autocomplete my custom annotation name, but it can't import it. As from I read, the problem is that you can't access classes from BOOT-INF package of a jar, but I don't understand how can you write a starter then. Configuration class

pom.xml

starter jar structure

CodePudding user response:

You've written your project to be a Spring Boot application. Spring Boot starters shouldn't be applications though, they should be simple JAR files like any other library, plus perhaps some configuration files like META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports (which has replaced META-INF/spring.factories in Spring Boot 2.7).

You probably only need to remove the Spring Boot plugin from your project, and the result will no longer contain a BOOT-INF folder or the Spring Boot specific stuff, just your classes and resources (which may include META-INF/spring.factories of course).

  • Related