• 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/
    

     

  • 相关阅读:
    Windows 运行 中的命令
    Base64 实现。名家手笔
    熊猫烧香病毒专杀及手动修复方案
    pdf病毒的源代码(VBS)
    Base64 实现。名家手笔
    pdf病毒的源代码(VBS)
    Code:关于加密解密 Base64 and URL and Hex Encoding and Decoding
    wmDrawer:实用的步骤启动器
    gnormalize:音频转换对象
    Avidemux:视频编纂软件
  • 原文地址:https://www.cnblogs.com/walxt/p/14322962.html
Copyright © 2020-2023  润新知