3.消费者的部署:
做个普通的maven project,quickstart archetype。改成jdk.8。过去我们都是:
@Service
public class LoginServiceImpl2 implements ILoginService {
public void login() {
System.out.println("LoginServiceImpl2");
}
}
我们的注解过去都写在类前面,而这次,如下图,注解写在了方法上,意味着,告诉Spring容器,运行以下方法,得到一个Bean实例,放在Spring容器中,以备将来调用:
@Bean
public RestTemplate restTemplate () {
return new RestTemplate ();
}
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>com</groupId>
<artifactId>eurekaMaven</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version>
<relativePath />
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
更多请看下节:http://www.mark-to-win.com/tutorial/frame_springCloud_ConsumerDeploy1.html
springCloud当中Eureca消费者Consumer的部署
最新推荐文章于 2024-04-27 23:20:35 发布