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












  • 相关阅读:
    一:多线程--多线程简单介绍
    五:网络--多线程断点下载
    四:网络--NSURLConnection基本使用
    三:网络--数据安全/加密
    二:网络--GET请求和POST请求
    一:网络--HTTP协议
    源代码管理工具GIT
    MyBatis 多参问题
    jquery 事件
    jquery点击事件
  • 原文地址:https://www.cnblogs.com/zzl0916/p/14037689.html
Copyright © 2020-2023  润新知