From 741c287c73f2073dc7b33d8e7821374c335ab8c5 Mon Sep 17 00:00:00 2001 From: wangkang Date: Tue, 3 Jul 2018 11:03:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=88=B0=20springboot2=20&?= =?UTF-8?q?=20F=E7=89=88=E6=9C=AC=20(=E6=9C=AA=E5=AE=8C=E6=88=90)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- udf-server/pom.xml | 4 ++-- udf-server/udf-admin-server/pom.xml | 2 +- .../server/UdfAdminServerApplication.java | 3 +-- .../main/resources/bootstrap-dev.properties | 4 ++-- .../main/resources/bootstrap-dev.properties | 5 ++-- udf-starter/pom.xml | 4 ++-- .../java/org/itkk/udf/auth/RmsFilter.java | 3 +-- .../udf/cache/redis/CacheRedisConfig.java | 24 +++++++++---------- .../udf/cache/redis/DefRedisCachePrefix.java | 5 ++-- udf-starter/udf-starter-core/pom.xml | 2 ++ .../core/domain/aliyun/oss/OssListParam.java | 2 +- .../exception/handle/ExceptionController.java | 6 ++--- .../handle/ExceptionControllerConfig.java | 6 ++++- .../xss/XssHttpServletRequestWrapper.java | 17 ++++++++++--- 14 files changed, 50 insertions(+), 37 deletions(-) diff --git a/udf-server/pom.xml b/udf-server/pom.xml index 8899b13..be4ed06 100644 --- a/udf-server/pom.xml +++ b/udf-server/pom.xml @@ -14,8 +14,8 @@ ${maven.build.timestamp} 1.0 1.0 - 1.5.14.RELEASE - Edgware.SR3 + 2.0.3.RELEASE + Finchley.RELEASE UTF-8 1.8 3.7.0 diff --git a/udf-server/udf-admin-server/pom.xml b/udf-server/udf-admin-server/pom.xml index 8e6daa3..2c13367 100644 --- a/udf-server/udf-admin-server/pom.xml +++ b/udf-server/udf-admin-server/pom.xml @@ -49,7 +49,7 @@ org.springframework.cloud - spring-cloud-starter-turbine + spring-cloud-starter-netflix-turbine diff --git a/udf-server/udf-admin-server/src/main/java/org/itkk/udf/admin/server/UdfAdminServerApplication.java b/udf-server/udf-admin-server/src/main/java/org/itkk/udf/admin/server/UdfAdminServerApplication.java index a5b74a1..6584ce8 100644 --- a/udf-server/udf-admin-server/src/main/java/org/itkk/udf/admin/server/UdfAdminServerApplication.java +++ b/udf-server/udf-admin-server/src/main/java/org/itkk/udf/admin/server/UdfAdminServerApplication.java @@ -6,6 +6,7 @@ */ package org.itkk.udf.admin.server; +import de.codecentric.boot.admin.config.EnableAdminServer; import org.itkk.udf.core.BaseApplication; import org.springframework.boot.SpringApplication; import org.springframework.cloud.client.SpringCloudApplication; @@ -14,8 +15,6 @@ 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 de.codecentric.boot.admin.config.EnableAdminServer; - /** * 描述 : 系统入口 * diff --git a/udf-server/udf-admin-server/src/main/resources/bootstrap-dev.properties b/udf-server/udf-admin-server/src/main/resources/bootstrap-dev.properties index b8a4dbc..c5ac248 100644 --- a/udf-server/udf-admin-server/src/main/resources/bootstrap-dev.properties +++ b/udf-server/udf-admin-server/src/main/resources/bootstrap-dev.properties @@ -1,8 +1,8 @@ ######################################################## ###security (must reboot) ######################################################## -security.user.name=admin -security.user.password=123456 +spring.security.user.name=admin +spring.security.user.password=123456 ######################################################## ###eureka.client ( EurekaInstanceConfigBean , EurekaClientConfigBean , EurekaServerConfigBean ) (must reboot) ######################################################## diff --git a/udf-server/udf-eureka-config-server/src/main/resources/bootstrap-dev.properties b/udf-server/udf-eureka-config-server/src/main/resources/bootstrap-dev.properties index e58d6e6..04556d1 100644 --- a/udf-server/udf-eureka-config-server/src/main/resources/bootstrap-dev.properties +++ b/udf-server/udf-eureka-config-server/src/main/resources/bootstrap-dev.properties @@ -1,8 +1,8 @@ ######################################################## ###security (must reboot) ######################################################## -security.user.name=admin -security.user.password=123456 +spring.security.user.name=admin +spring.security.user.password=123456 ######################################################## ###eureka.environment ( EurekaServerBootstrap ) (must reboot) ######################################################## @@ -11,6 +11,7 @@ eureka.environment=${spring.profiles.active} ###eureka.instance ( EurekaInstanceConfigBean ) (must reboot) ######################################################## eureka.instance.preferIpAddress=true +eureka.instance.instanceId=${spring.cloud.client.ipAddress}:${server.port} ######################################################## ###eureka.client (EurekaClientConfigBean , EurekaServerConfigBean ) (must reboot) ######################################################## diff --git a/udf-starter/pom.xml b/udf-starter/pom.xml index 01bb7f0..7cc3b8a 100644 --- a/udf-starter/pom.xml +++ b/udf-starter/pom.xml @@ -12,8 +12,8 @@ 1.0 - 1.5.14.RELEASE - Edgware.SR3 + 2.0.3.RELEASE + Finchley.RELEASE UTF-8 1.8 3.7.0 diff --git a/udf-starter/udf-starter-auth/src/main/java/org/itkk/udf/auth/RmsFilter.java b/udf-starter/udf-starter-auth/src/main/java/org/itkk/udf/auth/RmsFilter.java index 69a80f1..6808a7b 100644 --- a/udf-starter/udf-starter-auth/src/main/java/org/itkk/udf/auth/RmsFilter.java +++ b/udf-starter/udf-starter-auth/src/main/java/org/itkk/udf/auth/RmsFilter.java @@ -10,7 +10,6 @@ import org.itkk.udf.rms.RmsProperties; import org.itkk.udf.rms.meta.ApplicationMeta; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants; import org.springframework.stereotype.Component; import javax.servlet.http.HttpServletRequest; @@ -75,7 +74,7 @@ public class RmsFilter extends ZuulFilter { @Override public String filterType() { - return FilterConstants.PRE_TYPE; + return "pre"; } @Override diff --git a/udf-starter/udf-starter-cache-redis/src/main/java/org/itkk/udf/cache/redis/CacheRedisConfig.java b/udf-starter/udf-starter-cache-redis/src/main/java/org/itkk/udf/cache/redis/CacheRedisConfig.java index f63e446..281cf8c 100644 --- a/udf-starter/udf-starter-cache-redis/src/main/java/org/itkk/udf/cache/redis/CacheRedisConfig.java +++ b/udf-starter/udf-starter-cache-redis/src/main/java/org/itkk/udf/cache/redis/CacheRedisConfig.java @@ -3,12 +3,9 @@ package org.itkk.udf.cache.redis; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.PropertyAccessor; import com.fasterxml.jackson.databind.ObjectMapper; -import org.itkk.udf.core.ApplicationConfig; -import org.springframework.cache.CacheManager; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.data.redis.cache.RedisCacheManager; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; @@ -35,16 +32,17 @@ public class CacheRedisConfig { * @param redisTemplate redisTemplate * @return CacheManager */ - @Bean - public CacheManager cacheManager(ApplicationConfig applicationConfig, CacheRedisProperties cacheRedisProperties, RedisTemplate redisTemplate) { - RedisCacheManager cacheManager = new RedisCacheManager(redisTemplate); - cacheManager.setTransactionAware(true); - cacheManager.setUsePrefix(cacheRedisProperties.getUsePrefix()); - cacheManager.setCachePrefix(new DefRedisCachePrefix(cacheRedisProperties.getPrefix())); - cacheManager.setDefaultExpiration(cacheRedisProperties.getDefaultExpiration()); - cacheManager.setExpires(cacheRedisProperties.getNames()); - return cacheManager; - } + //@Bean + //public CacheManager cacheManager(ApplicationConfig applicationConfig, CacheRedisProperties cacheRedisProperties, RedisConnectionFactory factory) { + // RedisCacheManager cacheManager= RedisCacheManager.create(factory); + // cacheManager. + // cacheManager.setTransactionAware(true); + // cacheManager.setUsePrefix(cacheRedisProperties.getUsePrefix()); + // cacheManager.setCachePrefix(new DefRedisCachePrefix(cacheRedisProperties.getPrefix())); + // cacheManager.setDefaultExpiration(cacheRedisProperties.getDefaultExpiration()); + // cacheManager.setExpires(cacheRedisProperties.getNames()); + // return cacheManager; + //} /** * redisTemplate diff --git a/udf-starter/udf-starter-cache-redis/src/main/java/org/itkk/udf/cache/redis/DefRedisCachePrefix.java b/udf-starter/udf-starter-cache-redis/src/main/java/org/itkk/udf/cache/redis/DefRedisCachePrefix.java index e52e2cd..0bb941d 100644 --- a/udf-starter/udf-starter-cache-redis/src/main/java/org/itkk/udf/cache/redis/DefRedisCachePrefix.java +++ b/udf-starter/udf-starter-cache-redis/src/main/java/org/itkk/udf/cache/redis/DefRedisCachePrefix.java @@ -1,13 +1,12 @@ package org.itkk.udf.cache.redis; -import org.springframework.data.redis.cache.RedisCachePrefix; import org.springframework.data.redis.serializer.RedisSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; /** * DefRedisCachePrefix */ -public class DefRedisCachePrefix implements RedisCachePrefix { +public class DefRedisCachePrefix { /** * serializer */ @@ -28,7 +27,7 @@ public class DefRedisCachePrefix implements RedisCachePrefix { } - @Override + //@Override public byte[] prefix(String cacheName) { return serializer.serialize(prefix.concat(":")); } diff --git a/udf-starter/udf-starter-core/pom.xml b/udf-starter/udf-starter-core/pom.xml index 49542ac..40086d7 100644 --- a/udf-starter/udf-starter-core/pom.xml +++ b/udf-starter/udf-starter-core/pom.xml @@ -45,10 +45,12 @@ spring-boot-starter-actuator + org.springframework.boot diff --git a/udf-starter/udf-starter-core/src/main/java/org/itkk/udf/core/domain/aliyun/oss/OssListParam.java b/udf-starter/udf-starter-core/src/main/java/org/itkk/udf/core/domain/aliyun/oss/OssListParam.java index e5a9d3e..5e3d66c 100644 --- a/udf-starter/udf-starter-core/src/main/java/org/itkk/udf/core/domain/aliyun/oss/OssListParam.java +++ b/udf-starter/udf-starter-core/src/main/java/org/itkk/udf/core/domain/aliyun/oss/OssListParam.java @@ -3,8 +3,8 @@ package org.itkk.udf.core.domain.aliyun.oss; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import org.hibernate.validator.constraints.NotBlank; +import javax.validation.constraints.NotBlank; import java.io.Serializable; /** diff --git a/udf-starter/udf-starter-core/src/main/java/org/itkk/udf/core/exception/handle/ExceptionController.java b/udf-starter/udf-starter-core/src/main/java/org/itkk/udf/core/exception/handle/ExceptionController.java index 29474db..044951d 100644 --- a/udf-starter/udf-starter-core/src/main/java/org/itkk/udf/core/exception/handle/ExceptionController.java +++ b/udf-starter/udf-starter-core/src/main/java/org/itkk/udf/core/exception/handle/ExceptionController.java @@ -8,10 +8,10 @@ import org.itkk.udf.core.exception.ErrorResult; import org.itkk.udf.core.exception.PermissionException; import org.itkk.udf.core.exception.alert.IExceptionAlert; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.web.AbstractErrorController; -import org.springframework.boot.autoconfigure.web.ErrorAttributes; import org.springframework.boot.autoconfigure.web.ErrorProperties; -import org.springframework.boot.autoconfigure.web.ErrorViewResolver; +import org.springframework.boot.autoconfigure.web.servlet.error.AbstractErrorController; +import org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver; +import org.springframework.boot.web.servlet.error.ErrorAttributes; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/udf-starter/udf-starter-core/src/main/java/org/itkk/udf/core/exception/handle/ExceptionControllerConfig.java b/udf-starter/udf-starter-core/src/main/java/org/itkk/udf/core/exception/handle/ExceptionControllerConfig.java index d2f23da..b15a562 100644 --- a/udf-starter/udf-starter-core/src/main/java/org/itkk/udf/core/exception/handle/ExceptionControllerConfig.java +++ b/udf-starter/udf-starter-core/src/main/java/org/itkk/udf/core/exception/handle/ExceptionControllerConfig.java @@ -4,8 +4,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; -import org.springframework.boot.autoconfigure.web.*; +import org.springframework.boot.autoconfigure.web.ResourceProperties; +import org.springframework.boot.autoconfigure.web.ServerProperties; +import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration; +import org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.web.servlet.error.ErrorAttributes; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.DispatcherServlet; diff --git a/udf-starter/udf-starter-core/src/main/java/org/itkk/udf/core/xss/XssHttpServletRequestWrapper.java b/udf-starter/udf-starter-core/src/main/java/org/itkk/udf/core/xss/XssHttpServletRequestWrapper.java index 256b50d..03e6ea9 100644 --- a/udf-starter/udf-starter-core/src/main/java/org/itkk/udf/core/xss/XssHttpServletRequestWrapper.java +++ b/udf-starter/udf-starter-core/src/main/java/org/itkk/udf/core/xss/XssHttpServletRequestWrapper.java @@ -6,6 +6,7 @@ */ package org.itkk.udf.core.xss; +import org.apache.commons.lang3.StringUtils; import org.springframework.web.util.HtmlUtils; import javax.servlet.http.HttpServletRequest; @@ -30,13 +31,19 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { @Override public String getHeader(String name) { String value = super.getHeader(name); - return HtmlUtils.htmlEscape(value); + if (StringUtils.isNotBlank(value)) { + return HtmlUtils.htmlEscape(value); + } + return null; } @Override public String getParameter(String name) { String value = super.getParameter(name); - return HtmlUtils.htmlEscape(value); + if (StringUtils.isNotBlank(value)) { + return HtmlUtils.htmlEscape(value); + } + return null; } @Override @@ -46,7 +53,11 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { int length = values.length; String[] escapseValues = new String[length]; for (int i = 0; i < length; i++) { - escapseValues[i] = HtmlUtils.htmlEscape(values[i]); + if (StringUtils.isNotBlank(values[i])) { + escapseValues[i] = HtmlUtils.htmlEscape(values[i]); + } else { + escapseValues[i] = null; + } } return escapseValues; }