원래 dubbo 발표 서비스 가 이렇게 간단 합 니 다. springboot + dubbo
10286 단어 springboot
마이크로 서비스 기술 학습 https://www.itkc8.com
Dubbo 는 Alibaba 가 소스 를 오픈 하 는 분포 식 서비스 구조 로 가장 큰 특징 은 업무 별 구조 에 따라 이런 방식 을 사용 하면 각 업무 간 의 결합 (또는 최대한 느슨 한 결합) 을 풀 수 있다 는 것 이다.서비스 모델 의 측면 에서 볼 때 Dubbo 는 매우 간단 한 모델 을 사용 하 는데 제공 자가 서 비 스 를 제공 하거나 소비자 가 서 비 스 를 소비 하 는 것 이기 때문에 이 를 바탕 으로 서비스 제공 자 (Provider) 와 서비스 소비 자 (Consumer) 두 가지 역할 을 추상 화 할 수 있다.등록 센터, 협의 지원, 서비스 모니터링 등 내용 에 대해 서 는 다음 과 같이 설명 한다.spring - boot 는 최근 몇 년 동안 점점 유행 하 는 라 이브 러 리 로 Spring Boot 는 Spring 프레임 워 크 를 사용 할 때의 개발 효율 을 크게 향상 시 킬 수 있 습 니 다.spring - boot - starter - dubbo 는 spring - boot 의 효율 적 이 고 dubbo 를 통합 시 켜 dubbo 의 사용 을 서민 화 시킨다.
쾌속 입문
1. maven 이 관리 하 는 spring - boot 프로젝트 에 의존 도 를 도입 합 니 다. (spring - boot 버 전 1.5 이상, 1.5 이하 테스트 되 지 않 은 것 을 권장 합 니 다)
<dependency>
<groupId>com.gitee.regergroupId>
<artifactId>spring-boot-starter-dubboartifactId>
<version>${spring-boot-starter-dubbo.version}version>
dependency>
2. spring-boot ’application.yml’ dubbo
spring:
dubbo:
application:
name: demo-provider
base-package: com.test.dubbo.provider # dubbo
registry:
address: 127.0.0.1 # zookeeper
port: 2181 # zookeeper
protocol:
name: dubbo
serialization: hessian2
provider:
retries: 0 # , ,
spring:
dubbo:
application:
name: demo-consumer
base-package: com.test.dubbo.consumer # dubbo
registry:
address: 127.0.0.1 # zookeeper
port: 2181 # zookeeper
consumer:
timeout: 1000
check: true #
retries: 2 #
3. ,
api
package com.test.dubbo.service;
public interface DemoService {
Integer add(Integer a,Integer b);
}
4.
package com.test.dubbo.provider;
import com.test.dubbo.service.DemoService;
import com.alibaba.dubbo.config.annotation.Service;
@Service
public class DemoServiceImpl implements DemoService{
public Integer add(Integer a,Integer b){
System.err.printf(" add %s+%s", a, b);
System.err.println();
if(a==null||b==null){
return 0;
}
return a+b;
}
}
5.
package com.test.dubbo.consumer;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import com.alibaba.dubbo.config.annotation.Reference;
import com.reger.dubbo.annotation.Inject;
import com.test.dubbo.service.DemoService;
@Component
public class DemoConsumer implements CommandLineRunner {
// , dubbo @Reference
@Inject DemoService service;
@Override
public void run(String... args){
int a=1;
int b =2;
System.err.printf("%s+%s=%s", a, b, service.add(a,b));
System.err.println();
}
}
6. , 。
spring-boot main
package com.test.dubbo.main;
import java.util.concurrent.TimeUnit;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringDubboConfigApplication implements CommandLineRunner {
public static void main(String[] args) throws InterruptedException {
SpringApplication.run(SpringDubboConfigApplication.class, args);
TimeUnit.MINUTES.sleep(10); // main 10
System.err.println(" ------>> ");
}
@Override
public void run(String... args) throws Exception {
System.err.println(" ------>> ");
}
}
spring-boot main
package com.test.dubbo.main;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringDubboConfigApplication implements CommandLineRunner {
public static void main(String[] args) {
SpringApplication.run(SpringDubboConfigApplication.class, args);
}
@Override
public void run(String... args) throws Exception {
System.err.println(" ------>> ");
}
}
spring-boot-starter-dubbo-example
spring-boot-starter-dubbo
dubbo
spring-boot
jar rpc , app h5 restful api, restful spring-boot-starter-swagger
https://www.itkc8.com
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Kotlin Springboot -- 파트 14 사용 사례 REST로 전환하여 POST로 JSON으로 전환前回 前回 前回 記事 の は は で で で で で で を 使っ 使っ 使っ て て て て て リクエスト を を 受け取り 、 reqeustbody で 、 その リクエスト の ボディ ボディ を を 受け取り 、 関数 内部 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.