Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

希望增加热部署 #267

Open
zengyufei opened this issue Jun 4, 2024 · 5 comments
Open

希望增加热部署 #267

zengyufei opened this issue Jun 4, 2024 · 5 comments

Comments

@zengyufei
Copy link

热部署解决方案:https://github.com/Liubsyy/HotSecondsIDEA

Springboot 是校验过的:

1、添加 private 方法打印点东西,Controller 调用正常
2、添加 Controller 接口,postman 访问正常
3、添加 Service 接口, Service 实现,Controller 调用正常
4、添加 mapper default 方法,ServiceImpl 调用正常
5、添加 mapper 接口方法,添加 xml 实现,ServiceImpl 调用失败
6、修改 xml sql 语句,ServiceImpl 调用正常

尝试测试 Solon

简单尝试

通过测试,编写扩展代码,运行期间增加 Controller 接口能通过 postman 访问.

发现问题

但是会导致 main router 数组不断增加 一整个 Controller 的 API,因为 Solon 内部只是 add,并没有存在性的判断。

阶段性结论

所以,这件事只能官方来做,我提个建议。

附录

通过扩展 HotSecondsIDEA 实现

public class MyHotExtHandler implements IHotExtHandler{
    @Override
    public void preHandle(ClassLoader classLoader, String hotFilePath, byte[] content) {
        System.out.println("IHotExtHandler preHandle");

        try {
            BeanWrap beanWrap = new BeanWrap(Solon.context(), Class.forName(hotFilePath));
            FactoryManager.mvcFactory().createLoader(beanWrap).load(Solon.app());
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
}
@noear
Copy link
Member

noear commented Jun 4, 2024

路由器有移除接口的。。。可以参考下官网的热插拨示例

@noear
Copy link
Member

noear commented Jun 4, 2024

另外 solon 有官网的“热插拨”开发方法,官网也有。

@noear
Copy link
Member

noear commented Jun 4, 2024

https://solon.noear.org/article/273

solon 的“热插拨”插件,看下。。。上面有示例

@noear
Copy link
Member

noear commented Jun 5, 2024

Solon 2.8.4-SNAPSHOT ,增强了控制器的操作:

//添加控制器
Solon.app().router().add(beanWrap);

//移除控制器
Solon.app().router().remove(class);

你接着研究看看

@noear
Copy link
Member

noear commented Jun 5, 2024

另外,移除 bean 的接口:

Solon.context().removeWrap(class);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants