springboot自定义starter采坑记录,could not autowire,No beans of xxxx

阅读 119

2022-11-26


使用了springboot的各种starter,深感spi模式的方便,想着手动实现一个自定义starter,

详细步骤见:

​​springboot自定义starter实践_轻尘×的博客

结果一动手就问题频出,在将starter打成jar后,又遇到了无法引用的情况。

本地引入的jar,里面的内无法被注入

springboot自定义starter采坑记录,could not autowire,No beans of xxxx_spring boot

事故原因

第一次是因为spring.factories没有放在META-INF文件夹里,而是直接放在了resources文件夹下

springboot自定义starter采坑记录,could not autowire,No beans of xxxx_jar_02

第二次是因为复制粘贴的META-INF用来新建文件夹,导致前面多了一个空格

springboot自定义starter采坑记录,could not autowire,No beans of xxxx_自定义_03

 正确的创建方式后,spring.factories会显示图标的

springboot自定义starter采坑记录,could not autowire,No beans of xxxx_spring_04

感悟!切忌眼高手低,再简单的东西都要手动实践一遍!

精彩评论(0)

0 0 举报