spring cloud上手测试
软件架构说明 spring cloud相关框架测试
异常记录:
spring boot 2.0.0.RELEASE必须与cloud的Finchley.SR1(及以上版本搭配使用)否则报错: java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.([Ljava
若没有使用数据源则需要在主启动类加注解时加入exclude如:@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) 否则报错: Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded datasource could be auto-configured.
Parameter 0 of constructor in com.tao.springcloud.cfgbeans.ConfigBeans required a bean of type 'org.springframework.web.client.RestTemplate' that could not be found.
配置eureka集群时,hostname中不能有下划线 否则出现一下异常 o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is freemarker.core.InvalidReferenceException: The following has evaluated to null or missing: ==> replica.key [in template "eureka/navbar.ftl" at line 68, column 62]
spring cloud2 hystrix没有/actuator/hystrix.stream路径:需要在启动类添加servlet代码才能查看详见spring-cloud-server-hystrix启动类
IDEA操作记录:
1.热部署: 只需要添加devtools依赖即可 org.springframework.boot spring-boot-devtools true true JVM会定时扫描重新加载且仅加载有改动的类文件(.class文件),而不是加载所有的类文件,大大减少了类加载耗费的时间,从而实现热部署的功能。 Eclipse默认自动编译,而idea默认手动编译,因此idea需要修改两个参数以达到任意时间自动编译的目的。 首先,File->setting->搜索compiler->将Build project automatically打勾(yml可能需要在上面添加支持) (注意后面only works not running/debugging,所以我们要实现热部署就必须打破这个限制,于是乎有了下面设置) 然后,CTRL+ALT+SHIFT+/ 组合键打开 Maintenance窗口选择Registry... ,找到compiler.automake.allow.when.app.running选项,打勾开启运行时编译功能(找了半天才发现是按字母排序的)
思考: 1.spring-cloud-server在项目中可以看到是包含有3个module(server01/server02/server03),3个最大的区别在于数据源不同(代码相同),3个组合在一起类似于集群服务;在实际运用中应该是一套代码部署3套, 而不是像现在这样,或者本案例只是通过3个module模拟集群;(eureka集群也有类似问题)
####### hystrix: http://localhost:3083/hystrix
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。