sofastack / sofa-serverless

a framework to enabe app architecture evolve from monolithic to microservices smoothly by involving modular and macroservices architecture.
https://sofaserverless.gitee.io/home/
Apache License 2.0
115 stars 41 forks source link

支持模块 compile 引入 spring 框架依赖 #329

Closed lvjing2 closed 8 months ago

lvjing2 commented 9 months ago

问题描述

基座引入 runtime base starter 之后,无法支持模块里 compile 引入 spring 依赖,

Caused by: java.lang.IllegalArgumentException: class com.alipay.sofa.serverless.plugin.spring.ServerlessApplicationListener is not assignable to interface org.springframework.context.ApplicationListener
  at org.springframework.util.Assert.assignableCheckFailed(Assert.java:720)
  at org.springframework.util.Assert.isAssignable(Assert.java:651)
  at org.springframework.util.Assert.isAssignable(Assert.java:682)
  at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:483)
  ... 53 common frames omitted

具体原因可以查看 https://sofaserverless.gitee.io/docs/faq/import-full-springboot-in-module/

问题解决预期

在基座引入 base starter 下,模块也可以独立 compile 引入 spring 依赖

lvjing2 commented 9 months ago

cc @TomorJM

github-actions[bot] commented 8 months ago

This issue has been automatically marked as stale because it has not had recent activity in the last 30 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue or help wanted) or other activity occurs. Thank you for your contributions.

github-actions[bot] commented 8 months ago

This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue or help wanted. Thank you for your contributions.

lvjing2 commented 8 months ago

待 @TomorJM 分享下

lvjing2 commented 8 months ago

当前 SOFAServerless 无法 compile 的原因是,基座里引入了 https://github.com/sofastack/sofa-serverless/blob/master/sofa-serverless-runtime/arklet-springboot-starter/src/main/resources/META-INF/spring.factories,模块在启动的时候,会扫描到 ServerlessApplicationListener,但这个类是基座加载的,而对应的 org.springframework.context.ApplicationListener 由模块 compile 加载,导致失败。

未来 SOFAServerless 里将通过自动排包的方式,这些框架依赖统一让模块委托给基座加载。所以这个当前不做支持。