[XML] 纯文本查看 复制代码
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
<relativePath/><!--表示每次都不从本地仓库找jar包,优先从中央仓库找-->
</parent>
<dependencies>
<!-- SpringBoot整合Web组件 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
</dependencies>
[Java] 纯文本查看 复制代码
@SpringBootApplication
@EnableDiscoveryClient
@RestController
public class ConsulApp {
public static void main(String[] args) {
SpringApplication.run(ConsulApp.class, args);
}
@GetMapping("/testConsul")
public String testConsul(){
return "注册进入consul成功!";
}
}