yonge 5 anos atrás
pai
commit
f1c4c9b8b1

+ 15 - 9
mec-auth/mec-auth-server/pom.xml

@@ -23,30 +23,36 @@
 			<groupId>org.springframework.cloud</groupId>
 			<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
 		</dependency>
-		
+
 		<dependency>
 			<groupId>org.springframework.cloud</groupId>
 			<artifactId>spring-cloud-starter-oauth2</artifactId>
 		</dependency>
-		
+
 		<dependency>
 			<groupId>org.springframework.cloud</groupId>
 			<artifactId>spring-cloud-starter-security</artifactId>
 		</dependency>
-		
+
+		<dependency>
+			<groupId>de.codecentric</groupId>
+			<artifactId>spring-boot-admin-starter-client</artifactId>
+			<version>2.1.6</version>
+		</dependency>
+
 		<!-- swagger-spring-boot -->
 		<dependency>
 			<groupId>com.spring4all</groupId>
 			<artifactId>swagger-spring-boot-starter</artifactId>
 			<version>1.9.0.RELEASE</version>
 		</dependency>
-		
+
 		<dependency>
-            <groupId>com.alibaba</groupId>
-            <artifactId>druid-spring-boot-starter</artifactId>
-             <version>1.1.10</version>
-        </dependency>
-		
+			<groupId>com.alibaba</groupId>
+			<artifactId>druid-spring-boot-starter</artifactId>
+			<version>1.1.10</version>
+		</dependency>
+
 		<dependency>
 			<groupId>com.ym</groupId>
 			<artifactId>mec-auth-api</artifactId>

+ 13 - 2
mec-auth/mec-auth-server/src/main/resources/application.yml

@@ -48,9 +48,20 @@ spring:
       max-idle: 10
       #连接池中的最小空闲连接
       min-idle: 0
-    
+      
+         
 mybatis:
     mapperLocations: classpath:config/mybatis/*.xml
     
 swagger:
-  base-package: com.ym.mec.auth.controller
+  base-package: com.ym.mec.auth.controller
+  
+#spring boot admin 相关配置
+management:
+  endpoints:
+    web:
+      exposure:
+        include: "*"
+  endpoint:
+    health:
+      show-details: ALWAYS

+ 6 - 0
mec-gateway/mec-gateway-web/pom.xml

@@ -45,6 +45,12 @@
 			<artifactId>swagger-spring-boot-starter</artifactId>
 			<version>1.9.0.RELEASE</version>
 		</dependency>
+
+		<dependency>
+			<groupId>de.codecentric</groupId>
+			<artifactId>spring-boot-admin-starter-client</artifactId>
+			<version>2.1.6</version>
+		</dependency>
 	</dependencies>
 
 	<build>

+ 12 - 1
mec-gateway/mec-gateway-web/src/main/resources/application.yml

@@ -37,4 +37,15 @@ hystrix:
       execution: 
         isolation: 
           thread: 
-            timeoutInMilliseconds: 6000
+            timeoutInMilliseconds: 6000
+            
+            
+#spring boot admin 相关配置
+management:
+  endpoints:
+    web:
+      exposure:
+        include: "*"
+  endpoint:
+    health:
+      show-details: ALWAYS

+ 27 - 24
mec-monitor/pom.xml

@@ -1,26 +1,29 @@
 <?xml version="1.0"?>
-<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <groupId>com.ym</groupId>
-    <artifactId>mec</artifactId>
-    <version>1.0</version>
-  </parent>
-  <groupId>com.ym</groupId>
-  <artifactId>mec-monitor</artifactId>
-  <version>1.0</version>
-  <name>mec-monitor</name>
-  <url>http://maven.apache.org</url>
-  <properties>
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-  </properties>
-  <dependencies>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>3.8.1</version>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
+<project
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+	xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>com.ym</groupId>
+		<artifactId>mec</artifactId>
+		<version>1.0</version>
+	</parent>
+	<artifactId>mec-monitor</artifactId>
+	<name>mec-monitor</name>
+	<url>http://maven.apache.org</url>
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+	</properties>
+	<dependencies>
+		<dependency>
+			<groupId>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>de.codecentric</groupId>
+			<artifactId>spring-boot-admin-starter-server</artifactId>
+			<version>2.1.6</version>
+		</dependency>
+	</dependencies>
 </project>

+ 17 - 0
mec-monitor/src/main/java/com/ym/mec/monitor/MonitorApplication.java

@@ -0,0 +1,17 @@
+package com.ym.mec.monitor;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+
+import de.codecentric.boot.admin.server.config.EnableAdminServer;
+
+@SpringBootApplication
+@EnableDiscoveryClient
+@EnableAdminServer
+public class MonitorApplication {
+
+	public static void main(String[] args) {
+        SpringApplication.run(MonitorApplication.class, args);
+    }
+}

+ 29 - 0
mec-monitor/src/main/java/com/ym/mec/monitor/config/WebSecurityConfig.java

@@ -0,0 +1,29 @@
+package com.ym.mec.monitor.config;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
+
+import de.codecentric.boot.admin.server.config.AdminServerProperties;
+
+@Configuration
+public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
+	private final String adminContextPath;
+
+	public WebSecurityConfig(AdminServerProperties adminServerProperties) {
+		this.adminContextPath = adminServerProperties.getContextPath();
+	}
+
+	@Override
+	protected void configure(HttpSecurity http) throws Exception {
+		SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
+		successHandler.setTargetUrlParameter("redirectTo");
+		successHandler.setDefaultTargetUrl(adminContextPath + "/");
+
+		http.headers().frameOptions().disable().and().authorizeRequests()
+				.antMatchers(adminContextPath + "/assets/**", adminContextPath + "/login", adminContextPath + "/actuator/**").permitAll().anyRequest()
+				.authenticated().and().formLogin().loginPage(adminContextPath + "/login").successHandler(successHandler).and().logout()
+				.logoutUrl(adminContextPath + "/logout").and().httpBasic().and().csrf().disable();
+	}
+}

+ 27 - 0
mec-monitor/src/main/resources/application.yml

@@ -0,0 +1,27 @@
+server:
+  port: 8880
+
+eureka:
+  client:
+    serviceUrl:
+      ###配置中心的  用户名:密码@主机ip:端口/应用上下文/地址
+      defaultZone: http://admin:admin123@localhost:8761/eureka/eureka/
+
+spring:
+  application:
+    name: monitor-server
+  security:
+    user:
+      name: dyym
+      password: 123456
+
+management:
+  security: 
+    enabled: false
+  endpoints:
+    web:
+      exposure:
+        include: "*"
+  endpoint:
+    health:
+      show-details: ALWAYS

+ 61 - 24
mec-zipkin/pom.xml

@@ -1,26 +1,63 @@
 <?xml version="1.0"?>
-<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <groupId>com.ym</groupId>
-    <artifactId>mec</artifactId>
-    <version>1.0</version>
-  </parent>
-  <groupId>com.ym</groupId>
-  <artifactId>mec-zipkin</artifactId>
-  <version>1.0</version>
-  <name>mec-zipkin</name>
-  <url>http://maven.apache.org</url>
-  <properties>
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-  </properties>
-  <dependencies>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>3.8.1</version>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
+<project
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+	xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>com.ym</groupId>
+		<artifactId>mec</artifactId>
+		<version>1.0</version>
+	</parent>
+	<artifactId>mec-zipkin</artifactId>
+	<name>mec-zipkin</name>
+	<url>http://maven.apache.org</url>
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+	</properties>
+	<dependencies>
+
+		<dependency>
+			<groupId>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>io.zipkin.java</groupId>
+			<artifactId>zipkin-server</artifactId>
+			<version>2.12.9</version>
+			<!--排除log4j2 避免和logback冲突警告 -->
+			<exclusions>
+				<exclusion>
+					<groupId>org.springframework.boot</groupId>
+					<artifactId>spring-boot-starter-log4j2</artifactId>
+				</exclusion>
+			</exclusions>
+		</dependency>
+
+		<!-- 使用消息的方式收集数据(使用rabbitmq) -->
+		<dependency>
+			<groupId>io.zipkin.java</groupId>
+			<artifactId>zipkin-autoconfigure-collector-rabbitmq</artifactId>
+			<version>2.12.9</version>
+		</dependency>
+
+		<!-- 采用 elasticsearch 存储数据 -->
+		<dependency>
+			<groupId>io.zipkin.java</groupId>
+			<artifactId>zipkin-autoconfigure-storage-elasticsearch-http</artifactId>
+			<version>2.6.1</version>
+		</dependency>
+
+		<dependency>
+			<groupId>io.zipkin.java</groupId>
+			<artifactId>zipkin-autoconfigure-ui</artifactId>
+			<version>2.12.9</version>
+		</dependency>
+
+		<dependency>
+			<groupId>de.codecentric</groupId>
+			<artifactId>spring-boot-admin-starter-client</artifactId>
+			<version>2.1.6</version>
+		</dependency>
+	</dependencies>
 </project>

+ 18 - 0
mec-zipkin/src/main/java/com/ym/mec/zipkin/ZipkinServerApplication.java

@@ -0,0 +1,18 @@
+package com.ym.mec.zipkin;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+
+import zipkin2.server.internal.EnableZipkinServer;
+
+@SpringBootApplication
+@EnableDiscoveryClient
+@EnableZipkinServer
+public class ZipkinServerApplication {
+
+	public static void main(String[] args) {
+		SpringApplication.run(ZipkinServerApplication.class, args);
+	}
+	
+}

+ 44 - 0
mec-zipkin/src/main/resources/application.yml

@@ -0,0 +1,44 @@
+server:
+  port: 9999
+
+eureka:
+  client:
+    serviceUrl:
+      defaultZone: http://admin:admin123@localhost:8761/eureka/eureka/
+
+spring:
+  application:
+    name: zipkin-server
+  #rabbitmq配置
+  rabbitmq: 
+    addresses: amqp://192.168.10.47:5672
+    username: admin
+    password: admin123
+  
+    
+    
+zipkin: 
+  storage: 
+    StorageComponent: elasticsearch
+    type: elasticsearch
+    elasticsearch:  
+      cluster: elasticsearch-zipkin-cluster
+      hosts: 127.0.0.1:9300
+      max-requests: 64
+      index: zipkin
+      index-shards: 5
+      index-replicas: 1
+      
+      
+management:
+  security: 
+    enabled: false
+  endpoints:
+    web:
+      exposure:
+        include: "*"
+  endpoint:
+    health:
+      show-details: ALWAYS
+
+