当前位置: 首页 > news >正文

做一个信息网站多少钱环球易购做中东的网站

做一个信息网站多少钱,环球易购做中东的网站,网络营销seo教程,容桂低价网站建设在微服务架构的世界里#xff0c;Spring Cloud以其丰富的功能和简洁的编程模型成为了开发者的心头好。本文将深入探讨Spring Cloud启动类中的那些关键注解#xff0c;带你一步步解锁微服务开发的秘密。 1. 引言 Spring Cloud应用的启动类是微服务的大脑#xff0c;通过一系…在微服务架构的世界里Spring Cloud以其丰富的功能和简洁的编程模型成为了开发者的心头好。本文将深入探讨Spring Cloud启动类中的那些关键注解带你一步步解锁微服务开发的秘密。 1. 引言 Spring Cloud应用的启动类是微服务的大脑通过一系列的注解来装配和配置应用。了解这些注解的含义对于掌握Spring Cloud至关重要。接下来让我们一起探索这些神秘的注解并通过实例来加深理解。 2. Spring Cloud启动类注解全解析 2.1 SpringBootApplication三合一的便利 SpringBootApplication是Spring Boot的核心注解它集成了Configuration、EnableAutoConfiguration和ComponentScan。 SpringBootApplication public class MyApplication {public static void main(String[] args) {SpringApplication.run(MyApplication.class, args);} }Configuration表明该类使用Spring基于Java的配置。EnableAutoConfiguration让Spring Boot根据类路径中的jar包依赖为当前项目进行自动配置。ComponentScan自动扫描并加载符合条件的组件或bean定义通常是指标记了Component、Service、Controller等注解的类。 2.2 EnableDiscoveryClient发现服务的艺术 在微服务架构中服务发现是核心组件EnableDiscoveryClient注解让应用具有服务发现的能力。 EnableDiscoveryClient SpringBootApplication public class MyApplication {// ... }这个注解使得应用能够发现和注册到服务发现平台如Eureka、Consul、Zookeeper。 2.3 EnableFeignClients声明式的远程调用 EnableFeignClients注解允许开发者非常方便地实现服务之间的远程调用。 EnableFeignClients(basePackages com.example.clients) SpringBootApplication public class MyApplication {// ... }通过basePackages属性指定Feign Client接口的位置。 2.4 ComponentScan组件扫描的精细化控制 虽然SpringBootApplication包含了ComponentScan但有时我们需要更精细地控制扫描的路径。 ComponentScan(basePackages com.example.services) SpringBootApplication public class MyApplication {// ... }2.5 EnableTransactionManagement事务管理的自动化 EnableTransactionManagement注解用于启动Spring容器中的事务管理功能。 EnableTransactionManagement SpringBootApplication public class MyApplication {// ... }2.6 EnableSwagger2 EnableSwaggerBootstrapUIAPI文档的美观与实用 Swagger是一个规范和完整的框架用于生成、描述、调用和可视化RESTful风格的Web服务。 EnableSwagger2 EnableSwaggerBootstrapUI SpringBootApplication public class MyApplication {// ... }2.7 ConditionalOnClass条件装配的智慧 ConditionalOnClass注解让某些配置只在类路径下特定的类存在时才生效。 ConditionalOnClass(SpringfoxWebMvcConfiguration.class) SpringBootApplication public class MyApplication {// ... }3. 实战演练创建一个简单的Spring Cloud应用 现在我们将使用上述注解来创建一个简单的Spring Cloud服务。 3.1 创建启动类 EnableFeignClients(basePackages com.example.clients) EnableDiscoveryClient EnableTransactionManagement EnableSwagger2 EnableSwaggerBootstrapUI SpringBootApplication public class MyApplication {public static void main(String[] args) {SpringApplication.run(MyApplication.class, args);} }3.2 创建Feign客户端 FeignClient(name hello-service) public interface HelloClient {GetMapping(/hello)String hello(); }3.3 创建REST控制器 RestController public class HelloController {private final HelloClient helloClient;public HelloController(HelloClient helloClient) {this.helloClient helloClient;}GetMapping(/say-hello)public String sayHello() {return helloClient.hello();} }
http://www.zqtcl.cn/news/912530/

相关文章:

  • 合肥网站改版360免费建站永久免费
  • 商业网站建设案例课程 下载工信部企业网站认证
  • 泉州网站设计哪家公司好沈阳seo代理计费
  • 做景观素材有哪几个网站国内建网站费用
  • 驻马店重点项目建设网站wordpress常规选项
  • 网站开发 英文网站策划建设阶段的推广
  • 建立网站一般多少钱wordpress评论跳过验证
  • 南京每月做社保明细在哪个网站查看设计作品的网站软件
  • html怎么做网站如何在腾讯云上网站建设
  • 网站建设怎么链接表格手机做外贸有什么好的网站
  • 深圳开发网站建设哪家好外贸网络营销培训
  • 广州智迅网络做网站免费下载ps素材网站
  • 什么网站时候做伪静态开发软件定制
  • 找人做网站 多少钱西宁市公司网站建设
  • 网页设计 教程网站找权重高的网站方法
  • 网站建设本地还是外地重庆seo排名方法
  • 那个网站做网编好昨晚兰州发生了什么事
  • 温州建设局网站首页哪里可以学做资料员的网站
  • 网站怎样在360做优化wordpress文章图片在线裁剪
  • 彭州建设网站建设网站哪间公司比较好
  • qq空间网站根目录慧聪网首页
  • 制作小程序和网站的公司杭州品牌设计公司
  • 显示网站翻页代码wordpress 金融 模板下载
  • 用双语网站做seo会不会phpmysql网站
  • 长沙专业网站建设公司优惠券怎么做自己的网站
  • 做网站如何宣传怎么弄公众号
  • seo网站策划书网站建设资金投入
  • 做网站东莞东莞建网站wordpress 多文件上传
  • 公司注册流程聊城网站优化案例
  • 化妆品网站建设实施方案杭州seo代理公司