背景
准备体验liteflow: liteflow官网
新建了个springboot项目,JDK版本17,springboot版本默认的3.0.3,我就按着liteflow文档一步一步来的操作的,但是死活不行,怀疑人生…
问题
- 问题1:项目正常启动,但是接口请求不通:This application has no explicit mapping for /error, so you are seeing this as a fallback.
- 问题2:
然后我就找啊找,首先按照我Application的位置,应该是所有包下的内容都可以扫描到的,我就去掉了ComponentScan,去掉后直接无法启动:
A component required a bean of type ‘com.yomahub.liteflow.core.FlowExecutor’ that could not be found.
解决办法
真的很坑,Springboot3.0以上对应的SPI变了,但是liteflow里还没有支持。
@Resource
3.0 是import jakarta.annotation.Resource;
2.7.5是import javax.annotation.Resource;
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
import jakarta.annotation.Resource;
所以将Springboot的版本降到2.X即可
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
import javax.annotation.Resource;