springcloud

编程

package com.lovnx;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.boot.builder.SpringApplicationBuilder;

import org.springframework.cloud.config.server.EnableConfigServer;

@EnableConfigServer

@SpringBootApplication

public class ConfigApplication {

public static void main(String[] args) {

new SpringApplicationBuilder(ConfigApplication.class).web(true).run(args);

}

}

application.properties

spring.application.name=config-server

server.port=7072

gitu8FDCu7A0Bu914Du7F6E

#spring.cloud.config.server.git.uri=http://git.oschina.net/Lovnx/SC/

#spring.cloud.config.server.git.searchPaths=/config-repo

#spring.cloud.config.server.git.username=username

#spring.cloud.config.server.git.password=password

u6FC0u6D3Bu672Cu5730u914Du7F6E

spring.profiles.active=native

lovnx.properties

from=local

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>com.lovnx</groupId>

<artifactId>micro-service</artifactId>

<version>0.0.1-SNAPSHOT</version>

<packaging>pom</packaging>

<modules>

<module>ribbon</module>

<module>eureka-sever</module>

<module>config-server</module>

<module>zuul</module>

<module>service-A</module>

<module>service-B</module>

<module>service-B2</module>

<module>hystrix-ribbon</module>

<module>feign</module>

<module>hystrix-feign</module>

<module>hystrix-dashboard</module>

<module>turbine</module>

<module>service-admin</module>

<module>sleuth</module>

</modules>

<parent>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-parent</artifactId>

<version>1.5.2.RELEASE</version>

<relativePath/> <!-- lookup parent from repository -->

</parent>

</project>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>

<groupId>com.lovnx</groupId>

<artifactId>micro-service</artifactId>

<version>0.0.1-SNAPSHOT</version>

</parent>

<artifactId>config-server</artifactId>

<packaging>jar</packaging>

<properties>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<java.version>1.7</java.version>

</properties>

<dependencies>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-test</artifactId>

<scope>test</scope>

</dependency>

<dependency>

<groupId>org.springframework.cloud</groupId>

<artifactId>spring-cloud-config-server</artifactId>

</dependency>

</dependencies>

<dependencyManagement>

<dependencies>

<dependency>

<groupId>org.springframework.cloud</groupId>

<artifactId>spring-cloud-dependencies</artifactId>

<version>Camden.SR5</version>

<type>pom</type>

<scope>import</scope>

</dependency>

</dependencies>

</dependencyManagement>

<build>

<plugins>

<plugin>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-maven-plugin</artifactId>

</plugin>

</plugins>

</build>

</project>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>

<groupId>com.lovnx</groupId>

<artifactId>micro-service</artifactId>

<version>0.0.1-SNAPSHOT</version>

</parent>

<artifactId>eureka-sever</artifactId>

<packaging>jar</packaging>

<properties>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<java.version>1.7</java.version>

</properties>

<dependencies>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-test</artifactId>

<scope>test</scope>

</dependency>

<dependency>

<groupId>org.springframework.cloud</groupId>

<artifactId>spring-cloud-starter-eureka-server</artifactId>

</dependency>

</dependencies>

<dependencyManagement>

<dependencies>

<dependency>

<groupId>org.springframework.cloud</groupId>

<artifactId>spring-cloud-dependencies</artifactId>

<version>Camden.SR5</version>

<type>pom</type>

<scope>import</scope>

</dependency>

</dependencies>

</dependencyManagement>

<build>

<plugins>

<plugin>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-maven-plugin</artifactId>

</plugin>

</plugins>

</build>

</project>

package com.lovnx;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.boot.builder.SpringApplicationBuilder;

import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@EnableEurekaServer

@SpringBootApplication

public class EurekaServer {

public static void main(String[] args) {

new SpringApplicationBuilder(EurekaServer.class).web(true).run(args);

}

}

spring.application.name=eureka-server

server.port=7070

#eureka.instance.hostname=localhost

eureka.client.register-with-eureka=false

eureka.client.fetch-registry=false

eureka.client.serviceUrl.defaultZone=http://localhost:${server.port}/eureka/

<?xml version="1.0" encoding="UTF-8"?>

<!-- Logback configuration. See http://logback.qos.ch/manual/index.html -->

<configuration scan="true" scanPeriod="10 seconds">

<!--<include resource="org/springframework/boot/logging/logback/base.xml" />-->

<!--定义日志文件的存储地址和前缀名-->

<property name="LOG_HOME" value="F:/logs" />

<property name="LOG_PREFIX" value="micro-eureka-server" />

<!-- 一般信息按照每天生成日志文件 -->

<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">

<File>${LOG_HOME}/${LOG_PREFIX}-info.log</File>

<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">

<!-- 每天一归档 -->

<fileNamePattern>${LOG_HOME}/${LOG_PREFIX}-info-%d{yyyyMMdd}.log.%i</fileNamePattern>

<!-- 单个日志文件最多500MB, 30天的日志周期,最大不能超过20GB -->

<maxFileSize>100MB</maxFileSize>

<maxHistory>30</maxHistory>

<totalSizeCap>20GB</totalSizeCap>

</rollingPolicy>

<encoder>

<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->

<Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n</Pattern>

</encoder>

</appender>

<!--错误信息按照每天生成日志文件-->

<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">

<filter class="ch.qos.logback.classic.filter.ThresholdFilter">

<level>ERROR</level>

</filter>

<File>${LOG_HOME}/${LOG_PREFIX}-error.log</File>

<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">

<!-- 每天一归档 -->

<fileNamePattern>${LOG_HOME}/${LOG_PREFIX}-error-%d{yyyyMMdd}.log.%i</fileNamePattern>

<!-- 单个日志文件最多500MB, 30天的日志周期,最大不能超过20GB -->

<maxFileSize>100MB</maxFileSize>

<maxHistory>30</maxHistory>

<totalSizeCap>20GB</totalSizeCap>

</rollingPolicy>

<encoder>

<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->

<Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n</Pattern>

</encoder>

</appender>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">

<encoder>

<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->

<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>

</encoder>

</appender>

<!-- 日志输出级别 这样设置不打印日志 -->

<root level="INFO">

<!-- <appender-ref ref="STDOUT" /> -->

<appender-ref ref="INFO_FILE" />

<appender-ref ref="ERROR_FILE" />

</root>

</configuration>

以上是 springcloud 的全部内容, 来源链接: utcz.com/z/510405.html

回到顶部