- 一般是由第三方提供,数据放在压缩包里面,是json格式,这里简单的自己新加几个账户数据
- 接着继续创建子模块third-part-index-data-project,然后修改pom文件,增加web服务,增加eureka-client用于在注册中心作为微服务
<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.cashbook.trend</groupId>
<artifactId>trendParentProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>third-part-index-data-project</artifactId>
<name>third-part-index-data-project</name>
<description>third-part-index-data-project</description>
<dependencies>
<!--spring mvc-->
<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>
</project>
- 然后增加一个ThirdPartIndexDataApplication启动类
**package cn.cashbook.trend;
import cn.hutool.core.convert.Convert;
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;
@SpringBootApplication
@EnableEurekaClient
public class ThirdPartIndexDataApplication {
public static void main(String[] args) {
int port = 8090;
int eurekaServerPort = 8761;
if(NetUtil.isUsableLocalPort(eurekaServerPort)) {
System.err.printf("检查到%端口没有打开,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(ThirdPartIndexDataApplication.class).properties("server.port=" + port ).run(args);
}
}
**
- 增加个 application.yml.,说明注册中心的位置
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
spring:
application:
name: third-part-index-data-project
- 增加一些记账的数据,现在可以手动增加
注意数据要保存在resources下面 在http://127.0.0.1:8090/indexes/codes.json访问