1.使用goland打断点,断点变成了一个灰色带斜杠的禁用的图标,提示:executable not found之类的,尝试之后发现将Go Modules开启即可。

2.go-spring autowire can't find bean
报错信息
panic: can't find bean, bean: "" field: taskSvc.$RecordSvc type: core.RecordSvc [recovered]
panic: can't find bean, bean: "" field: taskSvc.$RecordSvc type: core.RecordSvc
自动注入后,启动就报错,后来参考源码中的测试包,
1)发现应该使用如下格式,其中的属性变量一定要大写开头:
type recordSvc struct {
DB *gorm.DB `autowire:""`
}
2)如果注入的是自己的接口
注册的时候要手动导出接口,防止一旦实例实现了多个接口能够找到指定接口。
func init() {
SpringBoot.RegisterNameBean("recordSvc", new(recordSvc)).
//AsInterface((*RecordSvc)(nil)). 已废弃
Export((*RecordSvc)(nil)).
ConditionOnBean("gorm")
}
网友评论