494250
前言
写一些简单的应用node比java方便太多了,如果有了spring加成岂不是更加如虎添翼,嘿嘿。
传送门
介绍
- 原生js实现
- 不依赖第三方库
- 不需要babel编译
- 开发模式与java的spring一致,运行时可以拿到注解。
代码用例
代码用例
主程序代码 ./app/Application.js
const {SpringProxy} = require('../spring')
//@Proxy(annotation=Service)
class TransactionManager {
//beanDefine:定义和注解 bean:实例
doProxy(beanDefine,bean){
return new SpringProxy(bean,{
method(wrapBean,method,args){
console.log(`TransactionManager: 拦截方法:${method} 参数替换:[${args} => 你好]`);
return wrapBean.invoke(["你好 "])
}
})
}
}
//@Service
class Service {
//@Value(config.app.msg)
appMsg;
say(userMsg){
return `${userMsg} ${this.appMsg} \n`;
}
}
//@SpringBoot
class Application {
//@SpringFactory
factory;
//@Autowired
service;
main(){
console.log(this.service.say("hello"))
}
}
module.exports = {Application,Service,TransactionManager}
启动代码 applicationBoot.js
const {SpringBoot} = require("./Spring")
//正式使用的时候 删除packageName属性
new SpringBoot({srcList:["./app"],packageName:"./spring"}).run();
一些感谢的话
感谢开源大佬和社区的贡献,世界有你们更精彩。
** 如果觉得还不错,麻烦给个星星🤭,方便在乌鲁木齐找个工作 讨碗饭吃 哈哈。 **