springboot 自定义starter项目Unable to read meta-data for class

springboot 自定义starter包,在项目中引用,启动报错。

org.springframework.boot.SpringApplication [SpringApplication.java:843] Application run failed
java.lang.IllegalStateException: Unable to read meta-data for class com.hxg.mail.springboot.config.HxgMailAutoConfigure

查看项目中的jar依赖引用,发现未包含自己定义的配置类,如下图

查看springboot starter包中的target目标,也没有配置类

查看springboot官网,springboot3的配置方式为

Spring Boot checks for the presence of a META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports file within your published jar. The file should list your configuration classes, with one class name per line, as shown in the following example:

com.mycorp.libx.autoconfigure.LibXAutoConfiguration
com.mycorp.libx.autoconfigure.LibXWebAutoConfiguration

即META-INF目标下创建spring目录,然后创建org.springframework.boot.autoconfigure.AutoConfiguration.imports文件,将配置类写入该文件。

改变配置类后依旧出现问题,后来发现springboot3依赖的是jdk17,我本地安装的是jdk12,将springboot版本改为springboot2后,打包正常。

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-configuration-processor</artifactId>
    <version>2.5.3</version>
</dependency>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-autoconfigure</artifactId>
    <version>2.5.3</version>
</dependency>            

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值