Explorar o código

springboot-actuator

MaxKey %!s(int64=4) %!d(string=hai) anos
pai
achega
cc2f20dd94

+ 8 - 3
build.gradle

@@ -201,9 +201,9 @@ subprojects {
 		 
 		 //kafka support
 		 // https://mvnrepository.com/artifact/org.apache.kafka/kafka-clients
-		 compile group: 'org.apache.kafka', name: 'kafka-clients', version: '2.5.0'
+		 compile group: 'org.apache.kafka', name: 'kafka-clients', version: '2.6.1'
 		 // https://mvnrepository.com/artifact/org.springframework.kafka/spring-kafka
-		 compile group: 'org.springframework.kafka', name: 'spring-kafka', version: '2.5.2.RELEASE'
+		 compile group: 'org.springframework.kafka', name: 'spring-kafka', version: '2.6.6'
 		 // https://mvnrepository.com/artifact/org.springframework.retry/spring-retry
 		 compile group: 'org.springframework.retry', name: 'spring-retry', version: '1.3.0'
 		 
@@ -215,6 +215,8 @@ subprojects {
          compile group: 'org.springframework.boot', name: 'spring-boot', version: "${springBootVersion}"
          compile group: 'org.springframework.boot', name: 'spring-boot-starter', version:  "${springBootVersion}"
          compile group: 'org.springframework.boot', name: 'spring-boot-actuator', version:  "${springBootVersion}"
+         compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version:  "${springBootVersion}"
+         compile group: 'org.springframework.boot', name: 'spring-boot-actuator-autoconfigure', version:  "${springBootVersion}"
          compile group: 'org.springframework.boot', name: 'spring-boot-autoconfigure', version:  "${springBootVersion}"
          compile group: 'org.springframework.boot', name: 'spring-boot-starter-freemarker', version:  "${springBootVersion}"
          compile group: 'org.springframework.boot', name: 'spring-boot-starter-log4j2', version:  "${springBootVersion}"
@@ -320,7 +322,10 @@ subprojects {
 		 compile group: 'org.ogce', name: 'xpp3', version: '1.1.6'
 		 compile group: 'com.thoughtworks.xstream', name: 'xstream', version: '1.4.10'
 		 compile group: 'org.passay', name: 'passay', version: '1.6.0'
-		 
+		 compile group: 'io.micrometer', name: 'micrometer-core', version: '1.6.4'
+		 compile group: 'org.latencyutils', name: 'LatencyUtils', version: '2.0.3'
+		 compile group: 'org.codehaus.woodstox', name: 'stax2-api', version: '4.2.1'
+		 		 
 		 //docs
 		 compile group: 'org.mapstruct', name: 'mapstruct', version: '1.4.1.Final'
 		 compile group: 'io.swagger', name: 'swagger-annotations', version: "${swaggerVersion}"

+ 3 - 0
maxkey-core/src/main/java/org/maxkey/autoconfigure/MvcAutoConfiguration.java

@@ -29,6 +29,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.InitializingBean;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.actuate.endpoint.http.ActuatorMediaType;
 import org.springframework.boot.web.server.ConfigurableWebServerFactory;
 import org.springframework.boot.web.server.ErrorPage;
 import org.springframework.boot.web.server.WebServerFactoryCustomizer;
@@ -174,6 +175,8 @@ public class MvcAutoConfiguration implements InitializingBean {
                 new MappingJackson2HttpMessageConverter();
         ArrayList<MediaType> mediaTypesList = new ArrayList<MediaType>();
         mediaTypesList.add(MediaType.APPLICATION_JSON);
+        mediaTypesList.add(MediaType.valueOf(ActuatorMediaType.V2_JSON));
+        mediaTypesList.add(MediaType.valueOf(ActuatorMediaType.V3_JSON));
         //mediaTypesList.add(MediaType.TEXT_PLAIN);
         mappingJacksonHttpMessageConverter.setSupportedMediaTypes(mediaTypesList);
         return mappingJacksonHttpMessageConverter;

+ 6 - 6
maxkey-core/src/main/java/org/maxkey/autoconfigure/RedisAutoConfiguration.java

@@ -49,19 +49,19 @@ public class RedisAutoConfiguration implements InitializingBean {
     public RedisConnectionFactory redisConnFactory(
             @Value("${spring.redis.host}")
             String host,
-            @Value("${spring.redis.port}")
+            @Value("${spring.redis.port:6379}")
             int port,
-            @Value("${spring.redis.timeout}")
+            @Value("${spring.redis.timeout:10000}")
             int timeout,
             @Value("${spring.redis.password}")
             String password,
-            @Value("${spring.redis.lettuce.pool.max-active}")
+            @Value("${spring.redis.lettuce.pool.max-active:-1}")
             int maxActive,
-            @Value("${spring.redis.jedis.pool.max-wait}")
+            @Value("${spring.redis.jedis.pool.max-wait:1000}")
             int maxWait,
-            @Value("${spring.redis.jedis.pool.max-idle}")
+            @Value("${spring.redis.jedis.pool.max-idle:100}")
             int maxIdle,
-            @Value("${spring.redis.lettuce.pool.min-idle}")
+            @Value("${spring.redis.lettuce.pool.min-idle:0}")
             int minIdle) {
         _logger.debug("redisConnFactory init .");
         RedisConnectionFactory factory = new RedisConnectionFactory();

+ 2 - 2
maxkey-core/src/main/java/org/maxkey/configuration/EmailConfig.java

@@ -35,10 +35,10 @@ public class EmailConfig {
     @Value("${spring.mail.host}")
     private String smtpHost;
     
-    @Value("${spring.mail.port}")
+    @Value("${spring.mail.port:465}")
     private Integer port;
     
-    @Value("${spring.mail.properties.ssl}")
+    @Value("${spring.mail.properties.ssl:false}")
     private boolean ssl;
     
     @Value("${spring.mail.properties.sender}")

+ 1 - 2
maxkey-web-manage/src/main/java/org/maxkey/MaxKeyMgtApplication.java

@@ -19,7 +19,6 @@ package org.maxkey;
 
 import java.util.Date;
 import javax.servlet.ServletException;
-
 import org.maxkey.configuration.ApplicationConfig;
 import org.maxkey.web.InitializeContext;
 import org.mybatis.spring.annotation.MapperScan;
@@ -32,7 +31,6 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
 import org.springframework.context.ConfigurableApplicationContext;
 import org.springframework.context.annotation.ComponentScan;
 
-@SpringBootApplication
 @ComponentScan(basePackages = {
     "org.maxkey.MaxKeyMgtConfig",
     "org.maxkey.MaxKeyMgtMvcConfig",
@@ -54,6 +52,7 @@ import org.springframework.context.annotation.ComponentScan;
     "org.maxkey.identity.rest"
 })
 @MapperScan("org.maxkey.persistence.mapper,")
+@SpringBootApplication
 public class MaxKeyMgtApplication extends SpringBootServletInitializer {
 	private static final Logger _logger = LoggerFactory.getLogger(MaxKeyMgtApplication.class);
 

+ 26 - 17
maxkey-web-manage/src/main/resources/application.properties

@@ -25,24 +25,25 @@ mybatis.type-aliases-package=org.maxkey.domain,org.maxkey.domain.apps,
 mybatis.mapper-locations=classpath*:/org/maxkey/persistence/mapper/xml/mysql/*.xml
 mybatis.table-column-escape=true
 #redis
-spring.redis.host=127.0.0.1
-spring.redis.port=6379
-spring.redis.password=password
-spring.redis.timeout=10000
-spring.redis.jedis.pool.max-wait=1000
-spring.redis.jedis.pool.max-idle=200
-spring.redis.lettuce.pool.max-active=-1
-spring.redis.lettuce.pool.min-idle=0
+#spring.redis.host=127.0.0.1
+#spring.redis.port=6379
+#spring.redis.password=password
+#spring.redis.timeout=10000
+#spring.redis.jedis.pool.max-wait=1000
+#spring.redis.jedis.pool.max-idle=200
+#spring.redis.lettuce.pool.max-active=-1
+#spring.redis.lettuce.pool.min-idle=0
 
 #mail
-spring.mail.default-encoding=utf-8
-spring.mail.host=smtp.163.com
-spring.mail.port=465
-spring.mail.username=maxkey@163.com
-spring.mail.password=password
-spring.mail.protocol=smtp
-spring.mail.properties.ssl=true
-spring.mail.properties.sender=maxkey@163.com
+#spring.mail.default-encoding=utf-8
+#spring.mail.host=smtp.163.com
+#spring.mail.port=465
+#spring.mail.username=maxkey@163.com
+#spring.mail.password=password
+#spring.mail.protocol=smtp
+#spring.mail.properties.ssl=true
+#spring.mail.properties.sender=maxkey@163.com
+
 #freemarker
 spring.freemarker.template-loader-path=classpath:/templates/views
 spring.freemarker.cache=false
@@ -91,4 +92,12 @@ spring.kafka.producer.buffer-memory = 33554432
 spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer
 spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer
 # \u81ea\u5b9a\u4e49\u5206\u533a\u5668
-# spring.kafka.producer.properties.partitioner.class=com.felix.kafka.producer.CustomizePartitioner
+# spring.kafka.producer.properties.partitioner.class=com.felix.kafka.producer.CustomizePartitioner
+
+#management.server.port=9522
+#management.server.servlet.context-path=/maxkey-mgt-actuate
+#management.endpoints.enabled-by-default=false
+management.security.enabled=false
+#management.endpoints.jmx.exposure.include=health,info
+management.endpoints.web.exposure.include=metrics,health,info,env,beans
+

+ 22 - 17
maxkey-web-maxkey/src/main/resources/application.properties

@@ -39,24 +39,24 @@ mybatis.mapper-locations=classpath*:/org/maxkey/persistence/mapper/xml/mysql/*.x
 mybatis.table-column-escape=true
 
 #redis
-spring.redis.host=127.0.0.1
-spring.redis.port=6379
-spring.redis.password=password
-spring.redis.timeout=10000
-spring.redis.jedis.pool.max-wait=1000
-spring.redis.jedis.pool.max-idle=200
-spring.redis.lettuce.pool.max-active=-1
-spring.redis.lettuce.pool.min-idle=0
+#spring.redis.host=127.0.0.1
+#spring.redis.port=6379
+#spring.redis.password=password
+#spring.redis.timeout=10000
+#spring.redis.jedis.pool.max-wait=1000
+#spring.redis.jedis.pool.max-idle=200
+#spring.redis.lettuce.pool.max-active=-1
+#spring.redis.lettuce.pool.min-idle=0
 
 #mail
-spring.mail.default-encoding=utf-8
-spring.mail.host=smtp.163.com
-spring.mail.port=465
-spring.mail.username=maxkey@163.com
-spring.mail.password=password
-spring.mail.protocol=smtp
-spring.mail.properties.ssl=true
-spring.mail.properties.sender=maxkey@163.com
+#spring.mail.default-encoding=utf-8
+#spring.mail.host=smtp.163.com
+#spring.mail.port=465
+#spring.mail.username=maxkey@163.com
+#spring.mail.password=password
+#spring.mail.protocol=smtp
+#spring.mail.properties.ssl=true
+#spring.mail.properties.sender=maxkey@163.com
 spring.mail.properties.mailotp.message.subject=MaxKey One Time PassWord
 spring.mail.properties.mailotp.message.template={0} You Token is {1} , it validity in {2}  minutes.
 
@@ -117,4 +117,9 @@ spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.Str
 maxkey.swagger.enable=true
 maxkey.swagger.title=MaxKey\u5355\u70b9\u767b\u5f55\u8ba4\u8bc1\u7cfb\u7edfapi\u6587\u6863
 maxkey.swagger.description=MaxKey\u5355\u70b9\u767b\u5f55\u8ba4\u8bc1\u7cfb\u7edfapi\u6587\u6863
-maxkey.swagger.version=${application.formatted-version}
+maxkey.swagger.version=${application.formatted-version}
+
+management.security.enabled=false
+#management.endpoints.jmx.exposure.include=health,info
+management.endpoints.web.exposure.include=metrics,health,info,env
+