This topic describes how to modify a local Dubbo project to connect to the SOFARegistry service registry.
Prerequisites
Before you start, you must configure the JAR package repository in your local Maven settings. This allows your project to download the service registry's JAR packages from the repository through Maven. The configuration is as follows:
Configuration path:
For Windows:
C:\Users\userName_XXX\.m2\settings.xmlFor macOS or Linux:
/Users/userName_XXX/.m2/settings.xmlImportantOn Linux and macOS, the
.m2folder may be hidden. On macOS, pressCommand + Shift + .to display it. On Linux, pressCtrl + Hto display it.
Configuration details:
Configure the address, username, and password for the
mvn.cloud.alipay.comrepository.The following example shows the configuration:
<servers> <server> <id>nexus-server@public</id> <username>${username}</username> <password>${password}</password> </server> <server> <id>nexus-server@public-snapshots</id> <username>${username}</username> <password>${password}</password> </server> <server> <id>mirror-all</id> <username>${username}</username> <password>${password}</password> </server> </servers>Update the mirror configuration for the development environment. This step is optional and is only required if you cannot download JAR packages locally.
If the mirror in your local Maven
settings.xmlfile (default path:~/.m2/settings.xml) is set to*, you must exclude thealipay-cloud-server@publicrepository, as shown in the following example:<mirror> <id>nexus-aliyun</id> <!-- <mirrorOf>*</mirrorOf> --> <mirrorOf>*,!alipay-cloud-server@public</mirrorOf> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror>Change the
mirrorOfsetting from*to*,!alipay-cloud-server@public. This excludes thealipay-cloud-server@publicrepository from the mirror.
Alternatively, you can download a pre-configured settings.xml file from the Scaffolding console. Then, navigate to the previously mentioned configuration path and use this file to overwrite the existing settings.xml file.
Procedure
Develop the application locally.
Add the repository address.
To ensure that the SDK and its corresponding tracer package can be downloaded, add the repository address to the root
pom.xmlfile of your project:<repositories> <repository> <id>alipay-cloud-server@public</id> <url>http://mvn.cloud.alipay.com/nexus/content/groups/open</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories>In the root
pom.xmlfile of your project, import thesofa-registry-cloud-allSDK dependency.For version information, see SDK Version Guide.
<dependency> <groupId>com.alipay.sofa</groupId> <artifactId>sofa-registry-cloud-all</artifactId> <!-- Replace x.x.x with the latest version number of the SDK --> <version>x.x.x</version> </dependency>NoteVersion 1.2.8 of the
sofa-registry-cloud-allSDK is compatible with all current versions of Dubbo applications.If you imported the SDK dependency using
sofa-registry-dubbo-all, you can directly upgrade it to thesofa-registry-cloud-alldependency.
Import the Tracer dependency.
Tracer provides the following three connection types based on your Dubbo application framework version. Choose the type that is appropriate for your application.
Spring Boot 1.x
<!-- for Spring Boot 1.X --> <dependency> <groupId>com.alipay.sofa</groupId> <artifactId>tracer-enterprise-sofa-boot-starter</artifactId> <version>2.3.7.JST.1</version> <exclusions> <exclusion> <groupId>com.alipay.sofa.common</groupId> <artifactId>sofa-common-tools</artifactId> </exclusion> <exclusion> <groupId>com.alipay.sofa</groupId> <artifactId>tracer-enterprise-dst-plugin</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.alipay.sofa.common</groupId> <artifactId>sofa-common-tools</artifactId> <version>1.0.17</version> </dependency>Spring Boot 2.x
<!-- for Spring Boot 2.X --> <dependency> <groupId>com.alipay.sofa</groupId> <artifactId>tracer-enterprise-sofa-boot-starter</artifactId> <version>3.2.3.JST.1</version> <exclusions> <exclusion> <groupId>com.alipay.sofa.common</groupId> <artifactId>sofa-common-tools</artifactId> </exclusion> <exclusion> <groupId>com.alipay.sofa</groupId> <artifactId>tracer-enterprise-dst-plugin</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.alipay.sofa.common</groupId> <artifactId>sofa-common-tools</artifactId> <version>1.0.17</version> </dependency>For Dubbo applications that do not use Spring Boot.
Import the same dependency as for Spring Boot 2.x.
In your code, add the following switch to the first line of the main method:
SofaTracerConfiguration.setProperty(SofaTracerConfiguration.JSON_FORMAT_OUTPUT,"false");
Configure the Dubbo service registry.
Use dsr:
<dubbo:registry address="dsr://dsr"/>.Add application startup parameters.
You can add them in any of the following ways:
Configure the following properties in the
dubbo.propertiesfile:NoteThe default path is
dubbo.propertiesin the root directory of the classpath. You can also manually specify the path using the JVM parameter-Ddubbo.properties.file=xxx.properties.com.alipay.instanceid= // The instance ID of the current account. com.antcloud.antvip.endpoint= // The AntVIP address value for the current region. com.antcloud.mw.access= // The AccessKey ID of the current account. com.antcloud.mw.secret= // The AccessKey secret of the current account.
Specify JVM startup parameter values:
-Dcom.alipay.instanceid= // The instance ID of the current account. -Dcom.antcloud.antvip.endpoint= // The AntVIP address value for the current region. -Dcom.antcloud.mw.access= // The AccessKey ID of the current account. -Dcom.antcloud.mw.secret= // The AccessKey secret of the current account.Specify system environment variables:
SOFA_INSTANCE_ID= // The instance ID of the current account. SOFA_ANTVIP_ENDPOINT= // The AntVIP address value for the current region. SOFA_ACCESS_KEY= // The AccessKey ID of the current account. SOFA_SECRET_KEY= // The AccessKey secret of the current account.
NoteThe preceding parameter values are global middleware configuration items. You can obtain them from the Scaffolding console. For more information, see Configuration guide.
Publish the application.
Log on to the SOFAStack console.
In the navigation pane on the left, choose Operations Management > Classic Application Service > Application Publishing > Release Ticket. Then, create and execute a release ticket.
For more information, see Create and execute a release ticket. After the application is published, you can view the service. In the navigation pane on the left, choose Middleware > Microservice Platform > Microservices > Service Management. The published service is displayed on the Service Management page.

View logs
You can view the service registry logs in /home/admin/logs/registry.
If you are using an older client runtime mode, view the logs in /home/admin/logs/confreg.