how2j.cn

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

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

步骤 1 : 先运行,看到效果,再学习   
步骤 2 : 模仿和排错   
步骤 3 : 拓扑图点亮   
步骤 4 : 采集与存储   
步骤 5 : 创建子模块   
步骤 6 : pom.xml   
步骤 7 : Index   
步骤 8 : IndexService   
步骤 9 : IndexController   
步骤 10 : IndexGatherStoreApplication   
步骤 11 : application.yml   
步骤 12 : 测试   
步骤 13 : 报错   

步骤 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 项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
增值内容,请先登录
完整的 SpringCloud 趋势量化投资项目,使用 Springboot 、Vue.js、redis, Zipkin, RabbitMQ, SpringCloud 等一整套技术栈, 从无到有涵盖全部59个知识点,378个开发步骤, 充实 SpringCloud 项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
创建子模块
增值内容,请先登录
完整的 SpringCloud 趋势量化投资项目,使用 Springboot 、Vue.js、redis, Zipkin, RabbitMQ, SpringCloud 等一整套技术栈, 从无到有涵盖全部59个知识点,378个开发步骤, 充实 SpringCloud 项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>cn.how2j.trend</groupId> <artifactId>trendParentProject</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <groupId>cn.how2j.trend</groupId> <artifactId>index-gather-store-service</artifactId> <dependencies> <!-- springboot web --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- eureka-client --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
增值内容,请先登录
完整的 SpringCloud 趋势量化投资项目,使用 Springboot 、Vue.js、redis, Zipkin, RabbitMQ, SpringCloud 等一整套技术栈, 从无到有涵盖全部59个知识点,378个开发步骤, 充实 SpringCloud 项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
package cn.how2j.trend.pojo; import java.io.Serializable; public class Index implements Serializable{ String code; String name; public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getName() { return name; } public void setName(String name) { this.name = name; } }
package cn.how2j.trend.pojo;

import java.io.Serializable;

public class Index implements Serializable{
	String code;
	String name;
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
}
增值内容,请先登录
完整的 SpringCloud 趋势量化投资项目,使用 Springboot 、Vue.js、redis, Zipkin, RabbitMQ, SpringCloud 等一整套技术栈, 从无到有涵盖全部59个知识点,378个开发步骤, 充实 SpringCloud 项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
package cn.how2j.trend.service; import cn.how2j.trend.pojo.Index; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; import java.util.ArrayList; import java.util.List; import java.util.Map; @Service public class IndexService { private List<Index> indexes; @Autowired RestTemplate restTemplate; public List<Index> fetch_indexes_from_third_part(){ List<Map> temp= restTemplate.getForObject("http://127.0.0.1:8090/indexes/codes.json",List.class); return map2Index(temp); } private List<Index> map2Index(List<Map> temp) { List<Index> indexes = new ArrayList<>(); for (Map map : temp) { String code = map.get("code").toString(); String name = map.get("name").toString(); Index index= new Index(); index.setCode(code); index.setName(name); indexes.add(index); } return indexes; } }
增值内容,请先登录
完整的 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.RestController; import cn.how2j.trend.pojo.Index; import cn.how2j.trend.service.IndexService; @RestController public class IndexController { @Autowired IndexService indexService; @GetMapping("/getCodes") public List<Index> get() throws Exception { return indexService.fetch_indexes_from_third_part(); } }
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.RestController;

import cn.how2j.trend.pojo.Index;
import cn.how2j.trend.service.IndexService;
 
@RestController
public class IndexController {
	@Autowired IndexService indexService;

	@GetMapping("/getCodes")
	public List<Index> get() throws Exception {
		return indexService.fetch_indexes_from_third_part();
	}
}

步骤 10 :

IndexGatherStoreApplication

edit
增值内容,请先登录
完整的 SpringCloud 趋势量化投资项目,使用 Springboot 、Vue.js、redis, Zipkin, RabbitMQ, SpringCloud 等一整套技术栈, 从无到有涵盖全部59个知识点,378个开发步骤, 充实 SpringCloud 项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
package cn.how2j.trend; import cn.hutool.core.convert.Convert; import cn.hutool.core.thread.ThreadUtil; import cn.hutool.core.util.NetUtil; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.cloud.netflix.eureka.EnableEurekaClient; import org.springframework.context.annotation.Bean; import org.springframework.web.client.RestTemplate; import java.util.Scanner; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @SpringBootApplication @EnableEurekaClient public class IndexGatherStoreApplication { public static void main(String[] args) { int port = 0; int defaultPort = 8001; int eurekaServerPort = 8761; port = defaultPort ; if(NetUtil.isUsableLocalPort(eurekaServerPort)) { System.err.printf("检查到端口%d 未启用,判断 eureka 服务器没有启动,本服务无法使用,故退出%n", eurekaServerPort ); System.exit(1); } if(null!=args && 0!=args.length) { for (String arg : args) { if(arg.startsWith("port=")) { String strPort= StrUtil.subAfter(arg, "port=", true); if(NumberUtil.isNumber(strPort)) { port = Convert.toInt(strPort); } } } } if(!NetUtil.isUsableLocalPort(port)) { System.err.printf("端口%d被占用了,无法启动%n", port ); System.exit(1); } new SpringApplicationBuilder(IndexGatherStoreApplication.class).properties("server.port=" + port).run(args); } @Bean RestTemplate restTemplate() { return new RestTemplate(); } }
增值内容,请先登录
完整的 SpringCloud 趋势量化投资项目,使用 Springboot 、Vue.js、redis, Zipkin, RabbitMQ, SpringCloud 等一整套技术栈, 从无到有涵盖全部59个知识点,378个开发步骤, 充实 SpringCloud 项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
eureka: client: serviceUrl: defaultZone: http://localhost:8761/eureka/ spring: application: name: index-gather-store-service
eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/
spring:
  application:
    name: index-gather-store-service
增值内容,请先登录
完整的 SpringCloud 趋势量化投资项目,使用 Springboot 、Vue.js、redis, Zipkin, RabbitMQ, SpringCloud 等一整套技术栈, 从无到有涵盖全部59个知识点,378个开发步骤, 充实 SpringCloud 项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
测试
增值内容,请先登录
完整的 SpringCloud 趋势量化投资项目,使用 Springboot 、Vue.js、redis, Zipkin, RabbitMQ, SpringCloud 等一整套技术栈, 从无到有涵盖全部59个知识点,378个开发步骤, 充实 SpringCloud 项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
报错


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


问答区域    
2021-08-28 为什么eureka包需要加版本号?
Tim99




maven基础不大好,问一个与项目“无关”的问题。 我在想为什么你的pom中,不用加版本号也能引入到jar包,而我的就一定要加,不然就会报空(即没引入)。 照我的想法,我在父工程中已经有这个了 <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.5.4</version> <relativePath/> <!-- lookup parent from repository --> </parent> 那springboot集成的jar里面,肯定有这spring-cloud-starter-netflix-eureka-client的包及其版本了,这样我就不需要写版本号了啊?然而我没写的话就是没引入,所以感觉很迷。 你的项目里面也没写版本,为什么能正确引入包?求解答。。。
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
            <version>3.0.3</version>
        </dependency>

							


2 个答案

疯一风
答案时间:2023-02-06
不加版本号能引入的情况,要么是parent的pom中已经引入过了。 要么就是在project标签中,用大括号,统一规定了所有依赖的版本

how2j
答案时间:2021-09-15
不需要用啊,在parent里有了就可以了呀。



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





2021-07-27 关于访问地址而返回的数据类型问题(XML和JSON)
luzhi0324




结果返回的值类型不是JSON,而是XML形式的解决. 将@GetMapping("/getCodes")注解改为 @RequestMapping(value="/getCodes", produces={"application/json; charset=UTF-8"}) 备注:返回json还是xml形式的解决方案如下: json: @RequestMapping(value="/getCodes", produces={"application/json; charset=UTF-8"}) xml: @RequestMapping(value="/getCodes", produces={"application/xml; charset=UTF-8"})
加载中
    @RequestMapping(value = "/getCodes", produces = {"application/json; charset=UTF-8"})
    public List<Index> get() {
        return indexService.parseMapTransferObject();
    }

							


1 个答案

how2j
答案时间:2021-08-21
谢谢分享



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





2021-07-05 视频录制的一些建议
2020-11-29 为什么没配yml文件,还可以成功注册到Eureka呀?
2020-07-03 上传github疑问?请教下站长


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

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

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

上传截图