Browse Source

consul版本

consul
yirenyishi 6 years ago
parent
commit
666a2af2bb
  1. 3
      sc-config/build.gradle
  2. 3
      sc-config/src/main/java/com/trgis/sb2sc/Sb2scConfigApplication.java
  3. 14
      sc-config/src/main/resources/application.yml
  4. 2
      sc-consumer/build.gradle
  5. 1
      sc-consumer/src/main/java/com/trgis/sb2sc/Sb2scConsumerApplication.java
  6. 2
      sc-consumer/src/main/resources/application.yml
  7. 15
      sc-consumer/src/main/resources/bootstrap.yml
  8. 8
      sc-dashboard/build.gradle
  9. 2
      sc-dashboard/src/main/java/com/trgis/sb2sc/Sb2scDashboardApplication.java
  10. 20
      sc-dashboard/src/main/resources/application.yml
  11. 27
      sc-eureka/.gitignore
  12. 41
      sc-eureka/build.gradle
  13. 14
      sc-eureka/src/main/java/com/trgis/sb2sc/Sb2scEurekaApplication.java
  14. 15
      sc-eureka/src/main/java/com/trgis/sb2sc/config/WebSecurityConfig.java
  15. 24
      sc-eureka/src/main/resources/application.yml
  16. 16
      sc-eureka/src/test/java/com/trgis/sb2sc/Sb2scApplicationTests.java
  17. 2
      sc-provider/build.gradle
  18. 2
      sc-provider/src/main/resources/application.yml
  19. 15
      sc-provider/src/main/resources/bootstrap.yml
  20. 2
      sc-zipkin/build.gradle
  21. 15
      sc-zipkin/src/main/resources/application.yml
  22. 2
      sc-zuul/build.gradle
  23. 15
      sc-zuul/src/main/resources/bootstrap.yml
  24. 2
      settings.gradle

3
sc-config/build.gradle

@ -31,11 +31,10 @@ jar{
}
dependencies {
compile('org.springframework.cloud:spring-cloud-starter-consul-discovery')
compile('org.springframework.cloud:spring-cloud-config-server')
compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-client')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.boot:spring-boot-starter-actuator')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
dependencyManagement {

3
sc-config/src/main/java/com/trgis/sb2sc/Sb2scConfigApplication.java

@ -4,11 +4,10 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.config.server.EnableConfigServer;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
@SpringBootApplication
@EnableConfigServer
@EnableDiscoveryClient
@SpringBootApplication
public class Sb2scConfigApplication {
public static void main(String[] args) {

14
sc-config/src/main/resources/application.yml

@ -15,11 +15,9 @@ spring:
git:
uri: https://git.coding.net/yirenyishi/springcloud-config-profile
searchPaths: '{application}'
eureka:
client:
service-url:
defaultZone: http://root:booszy@localhost:8761/eureka/
instance:
prefer-ip-address: true
instance-id: ${spring.application.name}:${spring.application.instance_id:${server.port}}
appname: sc-config-server
consul:
host: localhost
port: 8500
discovery:
instance-id: ${spring.application.name}:${spring.cloud.client.ipAddress}:${spring.application.instance_id:${server.port}}
ip-address: true

2
sc-consumer/build.gradle

@ -29,7 +29,7 @@ ext {
}
dependencies {
compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-client')
compile('org.springframework.cloud:spring-cloud-starter-consul-discovery')
compile('org.springframework.cloud:spring-cloud-starter-config')
compile('org.springframework.boot:spring-boot-starter-webflux')
compile('org.springframework.boot:spring-boot-starter-actuator')

1
sc-consumer/src/main/java/com/trgis/sb2sc/Sb2scConsumerApplication.java

@ -7,7 +7,6 @@ import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;

2
sc-consumer/src/main/resources/application.yml

@ -0,0 +1,2 @@
server:
port: 8200

15
sc-consumer/src/main/resources/bootstrap.yml

@ -1,12 +1,3 @@
eureka:
client:
service-url:
defaultZone: http://root:booszy@localhost:8761/eureka/
instance:
prefer-ip-address: true
instance-id: ${spring.application.name}:${spring.application.instance_id:${server.port}}
appname: sc-consumer
spring:
zipkin:
base-url: http://localhost:9411
@ -16,6 +7,12 @@ spring:
application:
name: sc-consumer
cloud:
consul:
host: localhost
port: 8500
discovery:
instance-id: ${spring.application.name}:${spring.cloud.client.ipAddress}:${spring.application.instance_id:${server.port}}
ip-address: true
config:
discovery:
enabled: true

8
sc-dashboard/build.gradle

@ -22,14 +22,16 @@ sourceCompatibility = 1.8
repositories {
mavenCentral()
}
ext {
springCloudVersion = 'Finchley.RELEASE'
}
configurations {
compile.exclude module: 'eureka-client'
}
dependencies {
compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-client')
compile('org.springframework.cloud:spring-cloud-starter-consul-discovery')
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.cloud:spring-cloud-starter-netflix-hystrix')
compile('org.springframework.cloud:spring-cloud-starter-netflix-hystrix-dashboard')

2
sc-dashboard/src/main/java/com/trgis/sb2sc/Sb2scDashboardApplication.java

@ -1,5 +1,6 @@
package com.trgis.sb2sc;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@ -10,6 +11,7 @@ import org.springframework.cloud.netflix.turbine.EnableTurbine;
@SpringBootApplication
@EnableTurbine
@EnableHystrixDashboard
@Qualifier("consulRegistration")
public class Sb2scDashboardApplication {
public static void main(String[] args) {
SpringApplication.run(Sb2scDashboardApplication.class, args);

20
sc-dashboard/src/main/resources/application.yml

@ -1,13 +1,5 @@
server:
port: 8900
eureka:
client:
service-url:
defaultZone: http://root:booszy@localhost:8761/eureka/
instance:
prefer-ip-address: true
instance-id: ${spring.application.name}:${spring.application.instance_id:${server.port}}
appname: sc-dashboard
turbine:
aggregator:
clusterConfig: default
@ -16,8 +8,10 @@ turbine:
spring:
application:
name: sc-dashboard
#management:
# endpoints:
# web:
# exposure:
# include: '*'
cloud:
consul:
host: localhost
port: 8500
discovery:
instance-id: ${spring.application.name}:${spring.cloud.client.ipAddress}:${spring.application.instance_id:${server.port}}
ip-address: true

27
sc-eureka/.gitignore

@ -1,27 +0,0 @@
.gradle
/build/
!gradle/wrapper/gradle-wrapper.jar
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
/out/
### NetBeans ###
/nbproject/private/
/build/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

41
sc-eureka/build.gradle

@ -1,41 +0,0 @@
buildscript {
ext {
springBootVersion = '2.0.3.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'com.trgis'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
ext {
springCloudVersion = 'Finchley.RELEASE'
}
dependencies {
compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-server')
compile('org.springframework.boot:spring-boot-starter-security')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}

14
sc-eureka/src/main/java/com/trgis/sb2sc/Sb2scEurekaApplication.java

@ -1,14 +0,0 @@
package com.trgis.sb2sc;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@EnableEurekaServer
@SpringBootApplication
public class Sb2scEurekaApplication {
public static void main(String[] args) {
SpringApplication.run(Sb2scEurekaApplication.class, args);
}
}

15
sc-eureka/src/main/java/com/trgis/sb2sc/config/WebSecurityConfig.java

@ -1,15 +0,0 @@
package com.trgis.sb2sc.config;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@EnableWebSecurity
class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().ignoringAntMatchers("/eureka/**");
super.configure(http);
}
}

24
sc-eureka/src/main/resources/application.yml

@ -1,24 +0,0 @@
server:
port: 8761
eureka:
datacenter: trmap
environment: product
server:
# 关闭自我保护
enable-self-preservation: false
# 清理服务器
eviction-interval-timer-in-ms: 5000
client:
healthcheck:
enabled: true
service-url:
defaultZone: http://root:booszy@localhost:8761/eureka/
register-with-eureka: false
fetch-registry: false
spring:
security:
basic:
enabled: true
user:
name: root
password: booszy

16
sc-eureka/src/test/java/com/trgis/sb2sc/Sb2scApplicationTests.java

@ -1,16 +0,0 @@
package com.trgis.sb2sc;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class Sb2scApplicationTests {
@Test
public void contextLoads() {
}
}

2
sc-provider/build.gradle

@ -29,7 +29,7 @@ ext {
}
dependencies {
compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-client')
compile('org.springframework.cloud:spring-cloud-starter-consul-discovery')
compile('org.springframework.cloud:spring-cloud-starter-config')
compile('org.springframework.boot:spring-boot-starter-webflux')
compile('org.springframework.boot:spring-boot-starter-actuator')

2
sc-provider/src/main/resources/application.yml

@ -0,0 +1,2 @@
server:
port: 8100

15
sc-provider/src/main/resources/bootstrap.yml

@ -1,16 +1,13 @@
eureka:
client:
service-url:
defaultZone: http://root:booszy@localhost:8761/eureka/
instance:
prefer-ip-address: true
instance-id: ${spring.application.name}:${spring.application.instance_id:${server.port}}
appname: sc-provider
spring:
application:
name: sc-provider
cloud:
consul:
host: localhost
port: 8500
discovery:
instance-id: ${spring.application.name}:${spring.cloud.client.ipAddress}:${spring.application.instance_id:${server.port}}
ip-address: true
config:
discovery:
enabled: true

2
sc-zipkin/build.gradle

@ -34,7 +34,7 @@ configurations {
}
dependencies {
compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-client')
compile('org.springframework.cloud:spring-cloud-starter-consul-discovery')
compile group: 'io.zipkin.java', name: 'zipkin-server', version: '2.9.3'
compile group: 'io.zipkin.java', name: 'zipkin-autoconfigure-ui', version: '2.9.3'
compile('org.springframework.boot:spring-boot-starter-actuator')

15
sc-zipkin/src/main/resources/application.yml

@ -5,14 +5,13 @@ spring:
name: sc-sc-zipkin
profiles:
active: csdn
eureka:
client:
service-url:
defaultZone: http://root:booszy@localhost:8761/eureka/
instance:
prefer-ip-address: true
instance-id: ${spring.application.name}:${spring.application.instance_id:${server.port}}
appname: sc-zipkin
cloud:
consul:
host: localhost
port: 8500
discovery:
instance-id: ${spring.application.name}:${spring.cloud.client.ipAddress}:${spring.application.instance_id:${server.port}}
ip-address: true
management:
metrics:
web:

2
sc-zuul/build.gradle

@ -29,7 +29,7 @@ ext {
}
dependencies {
compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-client')
compile('org.springframework.cloud:spring-cloud-starter-consul-discovery')
compile('org.springframework.cloud:spring-cloud-starter-config')
compile('org.springframework.cloud:spring-cloud-starter-netflix-zuul')
compile('org.springframework.boot:spring-boot-starter-actuator')

15
sc-zuul/src/main/resources/bootstrap.yml

@ -1,12 +1,3 @@
eureka:
client:
service-url:
defaultZone: http://root:booszy@localhost:8761/eureka/
instance:
prefer-ip-address: true
instance-id: ${spring.application.name}:${spring.application.instance_id:${server.port}}
appname: sc-zuul
spring:
zipkin:
base-url: http://localhost:9411
@ -16,6 +7,12 @@ spring:
application:
name: sc-zuul
cloud:
consul:
host: localhost
port: 8500
discovery:
instance-id: ${spring.application.name}:${spring.cloud.client.ipAddress}:${spring.application.instance_id:${server.port}}
ip-address: true
config:
discovery:
enabled: true

2
settings.gradle

@ -1,2 +1,2 @@
rootProject.name = 'sb2sc'
include('sc-eureka','sc-config','sc-provider','sc-consumer','sc-zuul','sc-dashboard','sc-zipkin')
include('sc-config','sc-provider','sc-consumer','sc-zuul','sc-dashboard','sc-zipkin')
Loading…
Cancel
Save