apache / dubbo-go

Go Implementation For Apache Dubbo .
https://dubbo.apache.org/
Apache License 2.0
4.71k stars 925 forks source link

panic: proxy factory for default is not existing #1420

Closed tonyjt closed 3 years ago

tonyjt commented 3 years ago

copy示例代码,或者自定义配置文件,都会出现错误:panic: proxy factory for default is not existing, make sure you have import the package.

` package main

import ( "context" "dubbo.apache.org/dubbo-go/v3/config" hessian "github.com/apache/dubbo-go-hessian2" gxlog "github.com/dubbogo/gost/log" "time" )

type User struct { ID string Name string Age int32 Time time.Time }

type UserProvider struct { }

func (u UserProvider) GetUser(ctx context.Context, req []interface{}) (User, error) { gxlog.CInfo("req:%#v", req) rsp := User{"A001", "Alex Stocks", 18, time.Now()} gxlog.CInfo("rsp:%#v", rsp) return &rsp, nil }

func (u *UserProvider) Reference() string { return "UserProvider" }

func (u User) JavaClassName() string { return "org.apache.dubbo.User" }

//

// needn't to setup environment variable before run func main() { hessian.RegisterPOJO(&User{}) config.SetProviderService(new(UserProvider)) providerConfig := config.NewProviderConfig( config.WithProviderAppConfig(config.NewDefaultApplicationConfig()), config.WithProviderProtocol("dubbo", "dubbo", "20000"), config.WithProviderRegistry("demoZk", config.NewDefaultRegistryConfig("zookeeper")), config.WithProviderServices("UserProvider", config.NewServiceConfigByAPI( config.WithServiceRegistry("demoZk"), config.WithServiceProtocol("dubbo"), config.WithServiceInterface("org.apache.dubbo.UserProvider"), config.WithServiceLoadBalance("random"), config.WithServiceWarmUpTime("100"), config.WithServiceCluster("failover"), config.WithServiceMethod("GetUser", "1", "random"), )), ) config.SetProviderConfig(*providerConfig) config.Load() }

`

What happened: 运行之后报错,panic: proxy factory for default is not existing, make sure you have import the package.

What you expected to happen: 正常启动

How to reproduce it (as minimally and precisely as possible): 拷贝代码启动,go版本:1.17

Anything else we need to know?:

tonyjt commented 3 years ago

dubbo-go版本:v3.0.0-rc2

AlexStocks commented 3 years ago

import _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"