in springcloud, I want to use consul as the registry, but the service registration always fails
my profile looks like this
server:
port: 9100
-sharp-sharp-sharp
spring:
application:
name: mzd-consul-member
cloud:
consul:
-sharp-sharpconsulip
host: 127.0.0.1
port: 8500
discovery:
-sharp-sharpip
hostname: 127.0.0.1
server:
port: 9200
-sharp-sharp-sharp
spring:
application:
name: mzd-consul-order
cloud:
consul:
-sharp-sharpconsulip
host: 127.0.0.1
port: 8500
discovery:
-sharp-sharpip
hostname: 127.0.0.1
pom file:
<!-- -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.M7</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<!--: -->
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/libs-milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
Startup class:
@SpringBootApplication
@EnableDiscoveryClient
public class ConsulorderApplication {
public static void main(String[] args) {
SpringApplication.run(ConsulorderApplication.class, args);
}
@Bean
@LoadBalanced
public RestTemplate getRestTemplate() {
return new RestTemplate();
}
}
excuse me, why has the registration been unsuccessful? Does consul need other operations? Both eureka and zookeeper can register successfully.