zoukankan      html  css  js  c++  java
  • nacos


    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 );
    }
    }












  • 相关阅读:
    QT,QVector 基本用法,遍历[实例讲解]
    QT boolinq
    Qt532.QString_填充字符
    QT AES加密
    允许ubuntu下mysql远程连接
    Curl参数一览
    PHP实现http与https转化
    LINUX查看硬件配置命令
    使用.htaccess的时候服务器出现500错误(在配置后台时出现)
    64位win7旗舰版搭建apache+php+mysql开发环境
  • 原文地址:https://www.cnblogs.com/zzl0916/p/14037689.html
Copyright © 2011-2022 走看看