zoukankan      html  css  js  c++  java
  • SpringCloud搭建服务中心

    // 搭建服务中心 构建Maven父子模块

    // 搭建eureka服务中心

    @SpringBootApplication
    @EnableEurekaServer
    public class EurekaApplication {
        private static final Logger LOGGER = LoggerFactory.getLogger(EurekaApplication.class);
    
    //    public static void main(String[] args) {
    //        SpringApplication.run(EurekaApplication.class, args);
    //    }
    
        public static void main(String[] args) {
            SpringApplication application = new SpringApplication(EurekaApplication.class);
            Environment environment = application.run(args).getEnvironment();
            LOGGER.info("start success !!!");
            LOGGER.info("Eureka address is : 	 http://127.0.0.1:{}",environment.getProperty("server.port"));
        }
    }
    

    // application.properties

    spring.application.name=eureka
    server.port=8761
    eureka.client.fetch-registry=false
    eureka.client.register-with-eureka=false
    

    //logback.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <!-- 修改一下路径 /log windows代表当前项目所在盘符下的log目录-->
        <property name="PATH" value="/log/course/eureka"></property>
    
        <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
            <encoder>
    <!--            <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %highlight(%-5level) %blue(%-50logger{50}:%-4line) %msg%n</Pattern>-->
                <Pattern>%d{ss.SSS} %highlight(%-5level) %blue(%-30logger{30}:%-4line) %msg%n</Pattern>
            </encoder>
        </appender>
    
        <appender name="TRACE_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <file>${PATH}/trace.log</file>
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
                <FileNamePattern>${PATH}/trace.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
                <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                    <maxFileSize>10MB</maxFileSize>
                </timeBasedFileNamingAndTriggeringPolicy>
            </rollingPolicy>
            <layout>
                <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %-50logger{50}:%-4line %green(%-8X{UUID}) %msg%n</pattern>
            </layout>
        </appender>
    
        <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <file>${PATH}/error.log</file>
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
                <FileNamePattern>${PATH}/error.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
                <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                    <maxFileSize>10MB</maxFileSize>
                </timeBasedFileNamingAndTriggeringPolicy>
            </rollingPolicy>
            <layout>
                <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %-50logger{50}:%-4line %green(%-8X{UUID}) %msg%n</pattern>
            </layout>
            <filter class="ch.qos.logback.classic.filter.LevelFilter">
                <level>ERROR</level>
                <onMatch>ACCEPT</onMatch>
                <onMismatch>DENY</onMismatch>
            </filter>
        </appender>
    
        <root level="ERROR">
            <appender-ref ref="ERROR_FILE" />
        </root>
    
        <root level="TRACE">
            <appender-ref ref="TRACE_FILE" />
        </root>
    
        <root level="INFO">
            <appender-ref ref="STDOUT" />
        </root>
    </configuration>
    

    //搭建eureka客户端 system

    @SpringBootApplication
    //将system模块注册到eureka服务中心
    @EnableEurekaClient
    public class SystemApplication {
        private static final Logger LOGGER = LoggerFactory.getLogger(SystemApplication.class);
    
    
        public static void main(String[] args) {
            SpringApplication application = new SpringApplication(SystemApplication.class);
            Environment environment = application.run(args).getEnvironment();
            LOGGER.info("start success !!!");
            LOGGER.info("System address is : 	 http://127.0.0.1:{}",environment.getProperty("server.port"));
        }
    }
    

    //application.properties

    spring.application.name=system
    server.port=9001
    eureka.client.service-url.defaultZone=http://localhost:8761/eureka/
    

     

  • 相关阅读:
    [技术项目4]--接口自动化数据一览项目总结
    [技术项目3]--流量回放项目总结
    [技术项目2]--禅道项目报告统计总结
    [技术项目1]--数据工厂项目总结
    自动化测试常用的框架
    【vue】element-表单中,下拉框选中某个值后,同步更新其他输入框的值
    【vue】vue打包后,将dist文件夹自动压缩成生成dist.zip压缩包--filemanager-webpack-plugin
    译文:ovs+dpdk中的“vHost User NUMA感知”特性
    vue中防抖,节流的使用
    横向结构的树组件(leader-line-vue)
  • 原文地址:https://www.cnblogs.com/walxt/p/14322962.html
Copyright © 2011-2022 走看看