spring cloud 服务相关配置

1.注册中心

1.1 添加pom依赖

	<dependencies>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
		</dependency>
	</dependencies>

	<build>
		<finalName>${project.artifactId}</finalName><!--打jar包去掉版本号-->
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>

1.2 编写启动类

@EnableEurekaServer
@SpringBootApplication

1.3 修改配置

spring:
  application:
    name: register-center
server:
  port: 8761
eureka:
  client:
    serviceUrl:
      defaultZone: http://local.register.com:${server.port}/eureka/
    register-with-eureka: true
    fetch-registry: false
    registry-fetch-interval-seconds: 5
  instance:
    lease-expiration-duration-in-seconds: 15
    lease-renewal-interval-in-seconds: 5
    prefer-ip-address: true
    instance-id: ${spring.application.name}:${server.port}
  server:
    enable-self-preservation: false
    eviction-interval-timer-in-ms: 3000
management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: always
logging:
  level:
    root: info
  file: logs/${spring.application.name}.log
posted @ 2021-04-21 16:10  易阳羽之灵异  阅读(51)  评论(0编辑  收藏  举报