package com.example.consumer8003.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
@RestController
public class ConsumerController {
@Autowired
private RestTemplate restTemplate;
/**
* 消费者去访问具体服务,这种写法可以实现
* 配置文件和代码的分离
*/
@Value("${service-url.nacos-user-service}")
private String serverURL;
@GetMapping(value = "consumer/nacos")
public String getDiscovery(){
System.out.println(serverURL);
return restTemplate.getForObject(serverURL+"/demo", String.class);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
此代码为我的Nacos专栏的配套代码。 1. 包含config-3377、consumer-8003、springcloudalibaba-nacos-9001和springcloudalibaba-nacos-9002四个服务 2. spring-cloud-alibaba-version为2.2.5.RELEASE、spring-boot的版本为2.2.13.RELEASE
资源推荐
资源详情
资源评论
收起资源包目录
Spring Cloud Alibaba Nacos实现代码 (219个子文件)
ConsumerController.class 1KB
Consumer8003Application.class 1KB
Demo2Controller.class 964B
Demo1Controller.class 964B
SpringcloudalibabaNacos9002Application.class 921B
SpringcloudalibabaNacos9001Application.class 921B
ConfigClientController.class 870B
Config3377Application.class 836B
SpringcloudalibabaNacos9002ApplicationTests.class 646B
SpringcloudalibabaNacos9001ApplicationTests.class 646B
Consumer8003ApplicationTests.class 571B
Config3377ApplicationTests.class 561B
mvnw.cmd 7KB
mvnw.cmd 7KB
mvnw.cmd 7KB
mvnw.cmd 7KB
mvnw.cmd 7KB
.gitignore 395B
.gitignore 395B
.gitignore 395B
.gitignore 395B
.gitignore 395B
config-3377.iml 16KB
springcloudalibaba-nacos-9002.iml 16KB
springcloudalibaba-nacos-9001.iml 16KB
consumer-8003.iml 16KB
springcloudalibaba.iml 12KB
maven-wrapper.jar 57KB
maven-wrapper.jar 57KB
maven-wrapper.jar 57KB
maven-wrapper.jar 57KB
maven-wrapper.jar 57KB
ConsumerController.java 874B
Consumer8003Application.java 718B
ConfigClientController.java 597B
Demo1Controller.java 491B
Demo2Controller.java 489B
SpringcloudalibabaNacos9002Application.java 482B
SpringcloudalibabaNacos9001Application.java 482B
Config3377Application.java 431B
SpringcloudalibabaNacos9002ApplicationTests.java 261B
SpringcloudalibabaNacos9001ApplicationTests.java 261B
Consumer8003ApplicationTests.java 231B
Config3377ApplicationTests.java 227B
HELP.md 429B
HELP.md 429B
HELP.md 429B
HELP.md 429B
HELP.md 429B
mvnw 10KB
mvnw 10KB
mvnw 10KB
mvnw 10KB
mvnw 10KB
maven-wrapper.properties 233B
maven-wrapper.properties 233B
maven-wrapper.properties 233B
maven-wrapper.properties 233B
maven-wrapper.properties 233B
workspace.xml 10KB
pom.xml 2KB
compiler.xml 1KB
Project_Default.xml 1KB
pom.xml 1KB
pom.xml 1KB
pom.xml 1KB
pom.xml 1KB
modules.xml 955B
Maven__com_alibaba_cloud_spring_cloud_starter_alibaba_nacos_discovery_2_2_5_RELEASE.xml 839B
Maven__org_springframework_cloud_spring_cloud_starter_netflix_archaius_2_2_5_RELEASE.xml 822B
Maven__com_alibaba_cloud_spring_cloud_starter_alibaba_nacos_config_2_2_5_RELEASE.xml 818B
Maven__org_springframework_cloud_spring_cloud_starter_netflix_ribbon_2_2_5_RELEASE.xml 808B
Maven__org_springframework_boot_spring_boot_starter_validation_2_2_13_RELEASE.xml 776B
Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_2_13_RELEASE.xml 776B
Maven__org_springframework_cloud_spring_cloud_starter_openfeign_2_2_6_RELEASE.xml 773B
Maven__org_springframework_cloud_spring_cloud_netflix_archaius_2_2_6_RELEASE.xml 766B
Maven__org_springframework_cloud_spring_cloud_netflix_archaius_2_2_5_RELEASE.xml 766B
Maven__org_springframework_boot_spring_boot_starter_logging_2_2_13_RELEASE.xml 755B
Maven__org_springframework_cloud_spring_cloud_openfeign_core_2_2_6_RELEASE.xml 752B
Maven__org_springframework_cloud_spring_cloud_netflix_ribbon_2_2_6_RELEASE.xml 752B
Maven__org_springframework_cloud_spring_cloud_netflix_ribbon_2_2_5_RELEASE.xml 752B
Maven__org_springframework_boot_spring_boot_starter_tomcat_2_2_13_RELEASE.xml 748B
Maven__org_springframework_boot_spring_boot_autoconfigure_2_2_13_RELEASE.xml 741B
misc.xml 737B
Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_10_5.xml 736B
Maven__org_springframework_boot_spring_boot_starter_test_2_2_13_RELEASE.xml 734B
Maven__org_springframework_boot_spring_boot_starter_json_2_2_13_RELEASE.xml 734B
Maven__org_springframework_security_spring_security_crypto_5_2_8_RELEASE.xml 729B
Maven__org_springframework_boot_spring_boot_starter_web_2_2_13_RELEASE.xml 727B
Maven__org_springframework_boot_spring_boot_starter_aop_2_2_13_RELEASE.xml 727B
Maven__com_alibaba_cloud_spring_cloud_alibaba_commons_2_2_5_RELEASE.xml 727B
Maven__org_springframework_security_spring_security_rsa_1_0_9_RELEASE.xml 708B
Maven__org_springframework_cloud_spring_cloud_context_2_2_5_RELEASE.xml 703B
Maven__org_springframework_cloud_spring_cloud_commons_2_2_5_RELEASE.xml 703B
Maven__org_springframework_cloud_spring_cloud_commons_2_2_6_RELEASE.xml 703B
Maven__org_springframework_cloud_spring_cloud_starter_2_2_6_RELEASE.xml 703B
Maven__org_springframework_cloud_spring_cloud_context_2_2_6_RELEASE.xml 703B
Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml 700B
Maven__org_springframework_boot_spring_boot_starter_2_2_13_RELEASE.xml 699B
Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_10_5.xml 695B
共 219 条
- 1
- 2
- 3
资源评论
竹峰的风
- 粉丝: 759
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功