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












  • 相关阅读:
    Linux 自定义快捷命令
    Linux 用户登陆提示This account is currently not available
    Linux 切换用户提示Permission denied
    Netty核心组件之ChannelPipeline
    Netty核心组件之ChannelHandler
    Netty核心组件之Channel
    Netty核心组件之ChannlFuture
    Error creating bean with name 'eurekaAutoServiceRegistration'
    关于mysql数据库时间与java后台时间类型
    rabbitMQ-helloWorld
  • 原文地址:https://www.cnblogs.com/zzl0916/p/14037689.html
Copyright © 2011-2022 走看看