首页 > 其他 > 详细

nacos

时间:2020-11-25 22:31:26      阅读:41      评论:0      收藏:0      [点我收藏+]

bootstrap.properties

spring.application.name=example

spring.main.allow-bean-definition-overriding=true
spring.cloud.nacos.discovery.server-addr=192.168.1.114:8847
spring.cloud.nacos.config.file-extension=properties
spring.cloud.nacos.config.server-addr=192.168.1.114:8847
spring.cloud.nacos.config.group=DEFAULT_GROUP




<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.9.RELEASE</version>
</parent>


<!--引入SpringBoot等依赖-->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>

</dependency>


<!--Spring Cloud Alibaba-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>0.9.0.RELEASE</version>
</dependency>


<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<version>0.9.0.RELEASE</version>
</dependency>



</dependencies>
















import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@RefreshScope
@RestController
public class SayHelloController {


@ResponseBody
@GetMapping("/")
public String findAllUser( ){

return "11111";
}
}












import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.ComponentScan;

//使用SpringBootApplication注解的时候下面显示红线 那么采用@ComponentScan和@EnableAutoConfiguration注解替换 就不报错了
@EnableDiscoveryClient //注册


@SpringBootApplication
public class HelloWorldApplication {
public static void main(String[] args) {
SpringApplication.run( HelloWorldApplication.class, args );
}
}












nacos

原文:https://www.cnblogs.com/zzl0916/p/14037689.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!