Closed JemyXiao closed 3 years ago
whats the dubbo version? you use XML config or spring boot starter?
whats the dubbo version? you use XML config or spring boot starter?
dubbo version is 2.6.0 i use springboot starter ver=2.0.0
Please show us your dubbo service interface
Please show us your
dubbo service interface
i debug application start process, i find registerServiceBean not in,i am not sure because of that
May be you have to make sure that your dubbo service has been registed successfully.
@KevinClair i think it the dubbo-spring-boot-starter , not register spring bean, can you fix it?
May be you have to make sure that your dubbo service has been registed successfully.
i am sure dubbo service registed successful already.
@KevinClair i think it the dubbo-spring-boot-starter , not register spring bean, can you fix it?
ok. i will fix it.
@KevinClair i find another problem, i try registry ServiceBean successful,but when invoke AlibabaDubboServiceBeanListener handler method,line 101 method.getAnnotation(ShenyuDubboCilent.Class) is null. please look it together,thanks.
@KevinClair i find another problem, i try registry ServiceBean successful,but when invoke AlibabaDubboServiceBeanListener handler method,line 101 method.getAnnotation(ShenyuDubboCilent.Class) is null. please look it together,thanks.
Got it.
I think dubbo proxy bean maybe miss the annotation, if use dubbo annotation type..
I think dubbo proxy bean maybe miss the annotation, if use dubbo annotation type..
i agree with you, i hope it can be fixed together?
Hello @JemyXiao ,I've tried many times and it's all successful.Here are some of my configuration.
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.6.0</version>
</dependency>
* spring-dubbo.xml file
```java
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<dubbo:application name="demo-service"/>
<!-- 注册中心的ip地址 -->
<dubbo:registry protocol="zookeeper" address="localhost:2181"/>
<!-- 协议/端口-->
<dubbo:protocol name="dubbo" port="20880"/>
<!-- 暴露的接口 -->
<dubbo:service ref="dubboService" interface="com.example.demo.dubbo.TestService"
timeout="3000" />
</beans>
Service
@Service("dubboService")
public class TestServiceImpl implements TestService {
@Override
@ShenyuDubboClient(path = "/test")
public String test() {
return "haha";
}
}
shenyu:
client:
registerType: http #zookeeper #etcd #nacos #consul
serverLists: http://localhost:9095 #localhost:2181 #http://localhost:2379 #localhost:8848
props:
contextPath: /dubbo
appName: dubbo
nacosNameSpace: ShenyuRegisterCenter
port: 20888
And when I run my application.
@KevinClair He not use XML, used Annotation.....
@KevinClair He not use XML, used Annotation.....
Sorry, I run application with Annotation, It works as well.
@KevinClair He not use XML, used Annotation.....
Sorry, I run application with Annotation, It works as well.
please show detail your dubbo service impl
@KevinClair please remove dubbo config xml,retry add @Service dubbo Annotation
@KevinClair please remove dubbo config xml,retry add @service dubbo Annotation
I try it and works as well.
import com.alibaba.dubbo.config.annotation.Service;
import com.example.demo.dubbo.TestService;
import org.apache.shenyu.client.dubbo.common.annotation.ShenyuDubboClient;
import org.springframework.stereotype.Component;
/**
* Des
*
* @author kevin
* @date 2021/5/12 16:57
**/
@Component
@Service
public class TestServiceImpl implements TestService {
@Override
@ShenyuDubboClient(path = "/test")
public String test() {
return "haha";
}
}
@KevinClair Hi, @Services is Dubbo Annotaion, not spring
@KevinClair please remove dubbo config xml,retry add @service dubbo Annotation
I try it and works as well.
import com.alibaba.dubbo.config.annotation.Service; import com.example.demo.dubbo.TestService; import org.apache.shenyu.client.dubbo.common.annotation.ShenyuDubboClient; import org.springframework.stereotype.Component; /** * Des * * @author kevin * @date 2021/5/12 16:57 **/ @Component @Service public class TestServiceImpl implements TestService { @Override @ShenyuDubboClient(path = "/test") public String test() { return "haha"; } }
in think your xml not remove
in think your xml not remove
I delete xml file.
Hello @JemyXiao , if you can, please send your simple example to my emil kevinclair@apache.org
so that we can check the problem.
Hello @JemyXiao , if you can, please send your simple example to my emil
kevinclair@apache.org
so that we can check the problem.
i use shenyu-examples-alibaba-dubbo-service module, i edit DubboTestServiceImpl use dubbo @Service Annotation, u can try it
Hello @JemyXiao , if you can, please send your simple example to my emil
kevinclair@apache.org
so that we can check the problem.i use shenyu-examples-alibaba-dubbo-service module, i edit DubboTestServiceImpl use dubbo @service Annotation, u can try it
Got it.
Hello @JemyXiao , I have found problem, you have to add @DubboComponentScan({"org.apache.shenyu.examples.alibaba.dubbo.service.impl"})
in the org.apache.shenyu.examples.alibaba.dubbo.service.TestAlibabaDubboApplication
to make sure Dubbo scan your interface with @Service
, just like this:
TestAlibabaDubboApplication
@SpringBootApplication
@ImportResource({"classpath:spring-dubbo.xml"})
@DubboComponentScan({"org.apache.shenyu.examples.alibaba.dubbo.service.impl"})
public class TestAlibabaDubboApplication {
/**
* Main Entrance.
*
* @param args startup arguments
*/
public static void main(final String[] args) {
SpringApplication.run(TestAlibabaDubboApplication.class, args);
}
}
* DubboTestServiceImpl
```java
package org.apache.shenyu.examples.alibaba.dubbo.service.impl;
import java.util.Arrays;
import java.util.Random;
import com.alibaba.dubbo.config.annotation.Service;
import org.apache.shenyu.client.dubbo.common.annotation.ShenyuDubboClient;
import org.apache.shenyu.examples.dubbo.api.entity.DubboTest;
import org.apache.shenyu.examples.dubbo.api.entity.ListResp;
import org.apache.shenyu.examples.dubbo.api.service.DubboTestService;
import org.springframework.stereotype.Component;
/**
* DubboTestServiceImpl.
*/
@Component("dubboTestService")
@Service
public class DubboTestServiceImpl implements DubboTestService {
@Override
@ShenyuDubboClient(path = "/findById", desc = "Query by Id")
public DubboTest findById(final String id) {
DubboTest dubboTest = new DubboTest();
dubboTest.setId(id);
dubboTest.setName("hello world shenyu Alibaba Dubbo, findById");
return dubboTest;
}
}
spring-dubbo.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<dubbo:application name="test-dubbo-service"/>
<dubbo:registry address="zookeeper://localhost:2181"/>
<dubbo:protocol name="dubbo" port="20888"/>
// you can also use this.
* if you delete spring-dubbo.xml, you have to add configuration in the application.yml and add `@EnableDubbo` in `TestAlibabaDubboApplication`, for example:
```java
@SpringBootApplication
@EnableDubbo
public class TestAlibabaDubboApplication {
/**
* Main Entrance.
*
* @param args startup arguments
*/
public static void main(final String[] args) {
SpringApplication.run(TestAlibabaDubboApplication.class, args);
}
}
dubbo:
application:
name: demo-service
registry:
protocol: zookeeper
address: localhost:2181
protocol:
name: dubbo
port: 20880
scan:
base-packages: org.apache.shenyu.examples.alibaba.dubbo.service.impl
@KevinClair thanks for patiently answer, i try it successfull follow your way. about another problem not found @ShenyuXXXClient Annotation from impl class, i fix it and pull request also.
@KevinClair thanks for patiently answer, i try it successfull follow your way. about another problem not found @ShenyuXXXClient Annotation from impl class, i fix it and pull request also.
But if you follow my way, @ShenyuXXXClient
would be found.
@KevinClair thanks for patiently answer, i try it successfull follow your way. about another problem not found @ShenyuXXXClient Annotation from impl class, i fix it and pull request also.
But if you follow my way,
@ShenyuXXXClient
would be found.
The scene is like this,I run my project not shenyu-example,my impl class generate spring proxy, so when handler method AopUtils.isCglibProxy() param type has a problem, i had pr. please code review my pr code
hi, branch: master class: AlibabaDubboServiceBeanListener method: onApplicationEvent env: springboot detail: init AlibabaDubboServiceBeanListener invoke onApplicationEvent Map<String, ServiceBean> serviceBean = contextRefreshedEvent.getApplicationContext().getBeansOfType(ServiceBean.class); serviceBean.size() = 0