4.0.0
com.zsw.example
order-api
1.3-SNAPSHOT
order-api
http://www.example.com
UTF-8
1.7
1.7
Hoxton.SR8
junit
junit
4.11
test
org.projectlombok
lombok
1.18.12
org.springframework.cloud
spring-cloud-starter-openfeign
org.springframework.cloud
spring-cloud-starter-netflix-ribbon
org.springframework.cloud
spring-cloud-dependencies
${spring-cloud.version}
pom
import
public interface MessageService {
@RequestMapping("/findAllList")
String findAllList();
@RequestMapping("/findById")
String findById();
}
@FeignClient("spring-cloud-message-service")
public interface MessageServiceFeignClient extends MessageService {
}
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.3.4.RELEASE
com.zsw
spring-cloud-message-service
0.0.1-SNAPSHOT
spring-cloud-message-service
Demo project for Spring Boot
1.8
Hoxton.SR8
org.springframework.boot
spring-boot-starter-web
org.projectlombok
lombok
true
org.springframework.boot
spring-boot-starter-test
test
org.junit.vintage
junit-vintage-engine
com.zsw.example
order-api
1.3-SNAPSHOT
org.springframework.cloud
spring-cloud-starter-netflix-eureka-client
org.springframework.cloud
spring-cloud-dependencies
${spring-cloud.version}
pom
import
org.springframework.boot
spring-boot-maven-plugin
@RestController
public class MessageServiceImpl implements MessageService {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Value(("${server.port}"))
private Integer port;
@Override
public String findAllList() {
System.out.println("MessageServiceImpl findAllList: " + format.format(new Date()));
return "find all message list by empty";
}
@Override
public String findById() {
System.out.println("MessageServiceImpl findById: " + format.format(new Date()));
return "find a message by id";
}
}
# 项目名称
spring:
application:
name: spring-cloud-message-service
server:
port: 8082
eureka:
client:
# 指向eureka注册中心地址,用来给服务端注册使用
service-url:
defaultZone: http://127.0.0.1:8777/eureka
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.3.4.RELEASE
com.zsw
spring-cloud-vehicle-service
0.0.1-SNAPSHOT
spring-cloud-vehicle-service
Demo project for Spring Boot
1.8
Hoxton.SR8
org.springframework.boot
spring-boot-starter-web
org.springframework.cloud
spring-cloud-starter-openfeign
org.projectlombok
lombok
true
org.springframework.boot
spring-boot-starter-test
test
org.junit.vintage
junit-vintage-engine
com.zsw.example
order-api
1.3-SNAPSHOT
org.springframework.cloud
spring-cloud-starter-netflix-eureka-client
org.springframework.cloud
spring-cloud-dependencies
${spring-cloud.version}
pom
import
org.springframework.boot
spring-boot-maven-plugin
# 项目名称
spring:
application:
name: spring-cloud-vehicle-service
server:
port: 6789
# ribbon配置指定服务提供者的地址,使用了eureka注册中心就不用这个配置了
#spring-cloud-message-service:
# ribbon:
# listOfServers:
# localhost:8082,localhost:8083
eureka:
client:
# 指向eureka注册中心地址,用来给服务端注册使用
service-url:
defaultZone: http://127.0.0.1:8777/eureka
@RestController
public class MessageFeignClientController {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Autowired
private MessageServiceFeignClient messageServiceFeignClient;
@RequestMapping("/findAllList")
public String findAllList() {
System.out.println("MessageFeignClientController findAllList 调用message服务查询信息集合: " + format.format(new Date()));
String allList = messageServiceFeignClient.findAllList();
System.out.println("message服务响应信息: " + allList);
return allList;
}
}
@EnableFeignClients("com.zsw.example.openfeign.client")
@SpringBootApplication
public class SpringCloudVehicleServiceApplication {
public static void main(String[] args) {
SpringApplication.run(SpringCloudVehicleServiceApplication.class, args);
}
}
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.3.4.RELEASE
com.zsw
spring-cloud-eureka-server
0.0.1-SNAPSHOT
spring-cloud-eureka-server
Demo project for Spring Boot
1.8
Hoxton.SR8
org.springframework.boot
spring-boot-starter-web
org.springframework.cloud
spring-cloud-starter-netflix-eureka-server
org.projectlombok
lombok
true
org.springframework.boot
spring-boot-starter-test
test
org.junit.vintage
junit-vintage-engine
org.springframework.cloud
spring-cloud-dependencies
${spring-cloud.version}
pom
import
org.springframework.boot
spring-boot-maven-plugin
server:
port: 8777
eureka:
client:
# eureka启动时注册自身,设置为false否则会报错,启动注册自己还没启动好呢
register-with-eureka: false
# eureka启动时加载服务端的配置信息(地址列表),设置为false否则会报错,启动注册自己还没启动好呢
fetch-registry: false
# 指向eureka注册中心地址,用来给服务端注册使用
service-url:
defaultZone: http://127.0.0.1:8777/eureka
@EnableEurekaServer
@SpringBootApplication
public class SpringCloudEurekaServerApplication {
public static void main(String[] args) {
System.out.println("eureka-server 启动");
SpringApplication.run(SpringCloudEurekaServerApplication.class, args);
}
}