how2j.cn

下载区
文件名 文件大小
请先登录 353k
增值内容 353k
353k

4分51秒
本视频采用html5方式播放,如无法正常播放,请将浏览器升级至最新版本,推荐火狐,chrome,360浏览器。 如果装有迅雷,播放视频呈现直接下载状态,请调整 迅雷系统设置-基本设置-启动-监视全部浏览器 (去掉这个选项)。 chrome 的 视频下载插件会影响播放,如 IDM 等,请关闭或者切换其他浏览器

步骤 1 : 先运行,看到效果,再学习   
步骤 2 : 模仿和排错   
步骤 3 : 指数数据   
步骤 4 : IndexData   
步骤 5 : IndexDataService   
步骤 6 : IndexDataController   
步骤 7 : 测试   

步骤 1 :

先运行,看到效果,再学习

edit
增值内容,请先登录
完整的 SpringCloud 趋势量化投资项目,使用 Springboot 、Vue.js、redis, Zipkin, RabbitMQ, SpringCloud 等一整套技术栈, 从无到有涵盖全部59个知识点,378个开发步骤, 充实 SpringCloud 项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
增值内容,请先登录
完整的 SpringCloud 趋势量化投资项目,使用 Springboot 、Vue.js、redis, Zipkin, RabbitMQ, SpringCloud 等一整套技术栈, 从无到有涵盖全部59个知识点,378个开发步骤, 充实 SpringCloud 项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
增值内容,请先登录
完整的 SpringCloud 趋势量化投资项目,使用 Springboot 、Vue.js、redis, Zipkin, RabbitMQ, SpringCloud 等一整套技术栈, 从无到有涵盖全部59个知识点,378个开发步骤, 充实 SpringCloud 项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
增值内容,请先登录
完整的 SpringCloud 趋势量化投资项目,使用 Springboot 、Vue.js、redis, Zipkin, RabbitMQ, SpringCloud 等一整套技术栈, 从无到有涵盖全部59个知识点,378个开发步骤, 充实 SpringCloud 项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
package cn.how2j.trend.pojo; public class IndexData { String date; float closePoint; public String getDate() { return date; } public void setDate(String date) { this.date = date; } public float getClosePoint() { return closePoint; } public void setClosePoint(float closePoint) { this.closePoint = closePoint; } }
package cn.how2j.trend.pojo;

public class IndexData {

	String date;
	float closePoint;
	public String getDate() {
		return date;
	}
	public void setDate(String date) {
		this.date = date;
	}
	public float getClosePoint() {
		return closePoint;
	}
	public void setClosePoint(float closePoint) {
		this.closePoint = closePoint;
	}
	
}
增值内容,请先登录
完整的 SpringCloud 趋势量化投资项目,使用 Springboot 、Vue.js、redis, Zipkin, RabbitMQ, SpringCloud 等一整套技术栈, 从无到有涵盖全部59个知识点,378个开发步骤, 充实 SpringCloud 项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
IndexDataService
package cn.how2j.trend.service; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CachePut; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; import cn.how2j.trend.pojo.IndexData; import cn.how2j.trend.util.SpringContextUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.convert.Convert; @Service @CacheConfig(cacheNames="index_datas") public class IndexDataService { private Map<String, List<IndexData>> indexDatas=new HashMap<>(); @Autowired RestTemplate restTemplate; @HystrixCommand(fallbackMethod = "third_part_not_connected") public List<IndexData> fresh(String code) { List<IndexData> indexeDatas =fetch_indexes_from_third_part(code); indexDatas.put(code, indexeDatas); System.out.println("code:"+code); System.out.println("indexeDatas:"+indexDatas.get(code).size()); IndexDataService indexDataService = SpringContextUtil.getBean(IndexDataService.class); indexDataService.remove(code); return indexDataService.store(code); } @CacheEvict(key="'indexData-code-'+ #p0") public void remove(String code){ } @CachePut(key="'indexData-code-'+ #p0") public List<IndexData> store(String code){ return indexDatas.get(code); } @Cacheable(key="'indexData-code-'+ #p0") public List<IndexData> get(String code){ return CollUtil.toList(); } public List<IndexData> fetch_indexes_from_third_part(String code){ List<Map> temp= restTemplate.getForObject("http://127.0.0.1:8090/indexes/"+code+".json",List.class); return map2IndexData(temp); } private List<IndexData> map2IndexData(List<Map> temp) { List<IndexData> indexDatas = new ArrayList<>(); for (Map map : temp) { String date = map.get("date").toString(); float closePoint = Convert.toFloat(map.get("closePoint")); IndexData indexData = new IndexData(); indexData.setDate(date); indexData.setClosePoint(closePoint); indexDatas.add(indexData); } return indexDatas; } public List<IndexData> third_part_not_connected(String code){ System.out.println("third_part_not_connected()"); IndexData index= new IndexData(); index.setClosePoint(0); index.setDate("n/a"); return CollectionUtil.toList(index); } }
步骤 6 :

IndexDataController

edit
增值内容,请先登录
完整的 SpringCloud 趋势量化投资项目,使用 Springboot 、Vue.js、redis, Zipkin, RabbitMQ, SpringCloud 等一整套技术栈, 从无到有涵盖全部59个知识点,378个开发步骤, 充实 SpringCloud 项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
package cn.how2j.trend.web; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; import cn.how2j.trend.pojo.IndexData; import cn.how2j.trend.service.IndexDataService; @RestController public class IndexDataController { @Autowired IndexDataService indexDataService; // http://127.0.0.1:8001/freshIndexData/000300 // http://127.0.0.1:8001/getIndexData/000300 // http://127.0.0.1:8001/removeIndexData/000300 @GetMapping("/freshIndexData/{code}") public String fresh(@PathVariable("code") String code) throws Exception { indexDataService.fresh(code); return "fresh index data successfully"; } @GetMapping("/getIndexData/{code}") public List<IndexData> get(@PathVariable("code") String code) throws Exception { return indexDataService.get(code); } @GetMapping("/removeIndexData/{code}") public String remove(@PathVariable("code") String code) throws Exception { indexDataService.remove(code); return "remove index data successfully"; } }
增值内容,请先登录
完整的 SpringCloud 趋势量化投资项目,使用 Springboot 、Vue.js、redis, Zipkin, RabbitMQ, SpringCloud 等一整套技术栈, 从无到有涵盖全部59个知识点,378个开发步骤, 充实 SpringCloud 项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢


HOW2J公众号,关注后实时获知最新的教程和优惠活动,谢谢。


问答区域    
2021-03-26 redis中container
佛说

请问站长redis中关于container类型 如何在redis-cli中创建呢,或者如何通过代码创建呢?我观测到@CacheConfig中的cacheNames都会对应创建一个container类型数据,我没法通过命令行直接获取container中的数据。 例如 get all_codes、get indexes::all_codes、select indexes +get all_codes都获取不到,网上关于container这个类型的也很少,站长能稍微说下这个类型吗?或者能提供下关于这个类型的网站吗?不胜感激




1 个答案

how2j
答案时间:2021-04-03
抱歉我对 redis_cli 也不太熟悉呢



回答已经提交成功,正在审核。 请于 我的回答 处查看回答记录,谢谢
答案 或者 代码至少填写一项, 如果是自己有问题,请重新提问,否则站长有可能看不到




2020-08-21 指数代码和基金代码会有重复吗
iceSnow

如题




1 个答案

how2j
答案时间:2020-08-23
不会呀,指数和基金代码是两套不同的代码,并不会重复呀



回答已经提交成功,正在审核。 请于 我的回答 处查看回答记录,谢谢
答案 或者 代码至少填写一项, 如果是自己有问题,请重新提问,否则站长有可能看不到




2020-07-17 redis爆卡
2020-07-09 如果redis中没数据的话,要自己手动去调用一下fresh方法?第一次都要先fresh?
2020-07-06 记一次错误


提问太多,页面渲染太慢,为了加快渲染速度,本页最多只显示几条提问。还有 7 条以前的提问,请 点击查看

提问之前请登陆
提问已经提交成功,正在审核。 请于 我的提问 处查看提问记录,谢谢
关于 实践项目-趋势投资SpringCloud-采集和储存微服务-指数数据 的提问

尽量提供截图代码异常信息,有助于分析和解决问题。 也可进本站QQ群交流: 578362961
提问尽量提供完整的代码,环境描述,越是有利于问题的重现,您的问题越能更快得到解答。
对教程中代码有疑问,请提供是哪个步骤,哪一行有疑问,这样便于快速定位问题,提高问题得到解答的速度
在已经存在的几千个提问里,有相当大的比例,是因为使用了和站长不同版本的开发环境导致的,比如 jdk, eclpise, idea, mysql,tomcat 等等软件的版本不一致。
请使用和站长一样的版本,可以节约自己大量的学习时间。 站长把教学中用的软件版本整理了,都统一放在了这里, 方便大家下载: https://how2j.cn/k/helloworld/helloworld-version/1718.html

上传截图