Closed wangeDear closed 4 months ago
can you provide a demo to reproduce it
Is unsuccessful registration accompanied by logging:
[DUBBO] Failed to create nacos config service client. Reason: server status check failed., dubbo version: xxx current host: xxx, error code: xxx. This may be caused by xxx
Using the dubbo spring boot demo of the official github, I updated the yml configuration file as follows. After startup, the service is not registered with nacos.
spring:
application:
name: dubbo-springboot-demo-provider
dubbo:
application:
name: ${spring.application.name}
protocol:
name: dubbo
port: -1
registry:
id: nacos-registry
address: nacos://10.133.128.64:8848?namespace=svtf_test
config-center:
address: nacos://10.133.128.64:8848?namespace=svtf_test
metadata-report:
address: nacos://10.133.128.64:8848?namespace=svtf_test
metrics:
protocol: prometheus
enable-jvm: true
enable-registry: true
aggregation:
enabled: true
prometheus:
exporter:
enabled: true
enable-metadata: true
services:
demoService:
interface: org.apache.dubbo.springboot.demo.DemoService
ref: demoServiceImpl
logging:
pattern:
level: '%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]'
DemoServiceImpl:
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.springboot.demo.provider;
import org.apache.dubbo.config.annotation.DubboService;
import org.apache.dubbo.rpc.RpcContext;
import org.apache.dubbo.springboot.demo.DemoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
//@DubboService
@Service
public class DemoServiceImpl implements DemoService {
private static final Logger logger = LoggerFactory.getLogger(DemoServiceImpl.class);
@Override
public String sayHello(String name) {
logger.info("Hello " + name + ", request from consumer: "
+ RpcContext.getContext().getRemoteAddress());
return "Hello " + name;
}
}
can you provide a demo to reproduce it demo updated
Using the dubbo spring boot demo of the official github, I updated the yml configuration file as follows. After startup, the service is not registered with nacos.
spring: application: name: dubbo-springboot-demo-provider dubbo: application: name: ${spring.application.name} protocol: name: dubbo port: -1 registry: id: nacos-registry address: nacos://10.133.128.64:8848?namespace=svtf_test config-center: address: nacos://10.133.128.64:8848?namespace=svtf_test metadata-report: address: nacos://10.133.128.64:8848?namespace=svtf_test metrics: protocol: prometheus enable-jvm: true enable-registry: true aggregation: enabled: true prometheus: exporter: enabled: true enable-metadata: true services: demoService: interface: org.apache.dubbo.springboot.demo.DemoService ref: demoServiceImpl logging: pattern: level: '%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]'
DemoServiceImpl:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dubbo.springboot.demo.provider; import org.apache.dubbo.config.annotation.DubboService; import org.apache.dubbo.rpc.RpcContext; import org.apache.dubbo.springboot.demo.DemoService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; //@DubboService @Service public class DemoServiceImpl implements DemoService { private static final Logger logger = LoggerFactory.getLogger(DemoServiceImpl.class); @Override public String sayHello(String name) { logger.info("Hello " + name + ", request from consumer: " + RpcContext.getContext().getRemoteAddress()); return "Hello " + name; } }
To give you my configuration, I think there are two places you need to pay attention to:
@wangeDear It seems you are using spring @Service annotation, not dubbo service annotation?why you not using @DubboService Annotation
@wangeDear It seems you are using spring @service annotation, not dubbo service annotation?why you not using @DubboService Annotation
You are right ,I overlooked that detail.
You can refer to this project @wangeDear https://github.com/apache/dubbo-samples/tree/fce381c2c11f87805dede48c4f18a8e336698c1a/1-basic/dubbo-samples-spring-boot
@wangeDear It seems you are using spring @service annotation, not dubbo service annotation?why you not using @DubboService Annotation
So, does it mean that Dubbo service registration cannot be configured and submitted only through the yml file?
Then how is the service configuration mentioned in the documentation used?
@wangeDear It seems you are using spring @service annotation, not dubbo service annotation?why you not using @DubboService Annotation
So, does it mean that Dubbo service registration cannot be configured and submitted only through the yml file?
Yes,When the project started, will be scanned to the package, and will be com.alibaba.dubbo.config.annotation.Service.class
. The class
Or maybe it's
org.apache.dubbo.config.annotation.Service.class
Or maybe it's
org.apache.dubbo.config.annotation.DubboService.class
The annotated classes perform service exposure and registration
Then how is the service configuration mentioned in the documentation used?
There are tutorials and instructions on the official website, and the corresponding code in this repository that you can follow https://github.com/apache/dubbo-samples
Then how is the service configuration mentioned in the documentation used?
There are tutorials and instructions on the official website, and the corresponding code in this repository that you can follow https://github.com/apache/dubbo-samples
Can you be more specific? there are no relevant configuration examples in the project you mentioned.
It appears that there is no configuration for services in the DubboConfigurationProperties
class
@wangeDear hello,any question? if not, this issue will close
Summary: can not used by this way,recommend used by annotation @AlbumenJ please close this issue
Pre-check
Search before asking
Apache Dubbo Component
Java SDK (apache/dubbo)
Dubbo Version
3.2.x
Steps to reproduce this issue
config services like this
What you expected to happen
service regist success
Anything else
No response
Are you willing to submit a pull request to fix on your own?
Code of Conduct