diff --git a/common/src/main/java/com/jeesite/common/collect/MapUtils.java b/common/src/main/java/com/jeesite/common/collect/MapUtils.java index 9a0aa874..12e7dcf1 100644 --- a/common/src/main/java/com/jeesite/common/collect/MapUtils.java +++ b/common/src/main/java/com/jeesite/common/collect/MapUtils.java @@ -84,7 +84,7 @@ public class MapUtils extends org.apache.commons.collections.MapUtils { * @param clazz * @param list */ - public static List toObjectList(Class clazz, List> list) throws IllegalAccessException, + public static List toObjectList(Class clazz, List> list) throws Exception, InvocationTargetException, NoSuchMethodException, InstantiationException { List retList = new ArrayList(); if (list != null && !list.isEmpty()) { @@ -100,9 +100,9 @@ public class MapUtils extends org.apache.commons.collections.MapUtils { * @param clazz 目标对象的类 * @param map 待转换Map */ - public static T toObject(Class clazz, Map map) throws InstantiationException, IllegalAccessException, + public static T toObject(Class clazz, Map map) throws Exception, InvocationTargetException { - T object = clazz.newInstance(); + T object = clazz.getDeclaredConstructor().newInstance(); return toObject(object, map); } @@ -112,9 +112,9 @@ public class MapUtils extends org.apache.commons.collections.MapUtils { * @param map 待转换Map * @param toCamelCase 是否去掉下划线 */ - public static T toObject(Class clazz, Map map, boolean toCamelCase) throws InstantiationException, IllegalAccessException, + public static T toObject(Class clazz, Map map, boolean toCamelCase) throws Exception, InvocationTargetException { - T object = clazz.newInstance(); + T object = clazz.getDeclaredConstructor().newInstance(); return toObject(object, map, toCamelCase); } diff --git a/common/src/main/java/com/jeesite/common/lang/NumberUtils.java b/common/src/main/java/com/jeesite/common/lang/NumberUtils.java index 9991c51f..80176bf7 100644 --- a/common/src/main/java/com/jeesite/common/lang/NumberUtils.java +++ b/common/src/main/java/com/jeesite/common/lang/NumberUtils.java @@ -4,6 +4,7 @@ package com.jeesite.common.lang; import java.math.BigDecimal; +import java.math.RoundingMode; import java.text.DecimalFormat; /** @@ -72,7 +73,7 @@ public class NumberUtils extends org.apache.commons.lang3.math.NumberUtils { } BigDecimal b1 = new BigDecimal(Double.toString(v1)); BigDecimal b2 = new BigDecimal(Double.toString(v2)); - return b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP).doubleValue(); + return b1.divide(b2, scale, RoundingMode.HALF_UP).doubleValue(); } /** @@ -81,7 +82,7 @@ public class NumberUtils extends org.apache.commons.lang3.math.NumberUtils { */ public static String formatDouble(Double b) { BigDecimal bg = new BigDecimal(b); - return bg.setScale(2, BigDecimal.ROUND_HALF_UP).toString(); + return bg.setScale(2, RoundingMode.HALF_UP).toString(); } /** @@ -90,7 +91,7 @@ public class NumberUtils extends org.apache.commons.lang3.math.NumberUtils { */ public static String formatScale(double one, long total) { BigDecimal bg = new BigDecimal(one * 100 / total); - return bg.setScale(0, BigDecimal.ROUND_HALF_UP).toString(); + return bg.setScale(0, RoundingMode.HALF_UP).toString(); } /** diff --git a/common/src/main/java/com/jeesite/common/mapper/XmlMapper.java b/common/src/main/java/com/jeesite/common/mapper/XmlMapper.java index a0c0870a..9ccad6ce 100644 --- a/common/src/main/java/com/jeesite/common/mapper/XmlMapper.java +++ b/common/src/main/java/com/jeesite/common/mapper/XmlMapper.java @@ -167,7 +167,6 @@ public class XmlMapper extends com.fasterxml.jackson.dataformat.xml.XmlMapper{ * @param element * @return */ - @SuppressWarnings("unchecked") private static Object xmlToMap(Element element) { // System.out.println(element.getName()); Map map = new LinkedHashMap(); @@ -212,7 +211,6 @@ public class XmlMapper extends com.fasterxml.jackson.dataformat.xml.XmlMapper{ * @param element * @return */ - @SuppressWarnings("unchecked") private static Object xmlToMapWithAttr(Element element) { // System.out.println(element.getName()); Map map = new LinkedHashMap(); diff --git a/common/src/main/java/com/jeesite/common/reflect/ClassUtils.java b/common/src/main/java/com/jeesite/common/reflect/ClassUtils.java index be6abf30..8dfe7895 100644 --- a/common/src/main/java/com/jeesite/common/reflect/ClassUtils.java +++ b/common/src/main/java/com/jeesite/common/reflect/ClassUtils.java @@ -288,14 +288,12 @@ abstract class VFS { for (int i = 0; vfs == null || !vfs.isValid(); i++) { Class impl = impls.get(i); try { - vfs = impl.newInstance(); + vfs = impl.getDeclaredConstructor().newInstance(); if (vfs == null || !vfs.isValid()) { log.debug("VFS implementation " + impl.getName() + " is not valid in this environment."); } - } catch (InstantiationException e) { - log.error("Failed to instantiate " + impl, e); - return null; - } catch (IllegalAccessException e) { + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException + | InvocationTargetException | NoSuchMethodException | SecurityException e) { log.error("Failed to instantiate " + impl, e); return null; } diff --git a/common/src/main/java/com/jeesite/common/utils/excel/ExcelExport.java b/common/src/main/java/com/jeesite/common/utils/excel/ExcelExport.java index 5ad06e1c..750e327b 100644 --- a/common/src/main/java/com/jeesite/common/utils/excel/ExcelExport.java +++ b/common/src/main/java/com/jeesite/common/utils/excel/ExcelExport.java @@ -230,8 +230,8 @@ public class ExcelExport implements Closeable{ Collections.sort(annotationList, new Comparator() { @Override public int compare(Object[] o1, Object[] o2) { - return new Integer(((ExcelField)o1[0]).sort()).compareTo( - new Integer(((ExcelField)o2[0]).sort())); + return Integer.valueOf(((ExcelField)o1[0]).sort()).compareTo( + Integer.valueOf(((ExcelField)o2[0]).sort())); }; }); // Initialize diff --git a/common/src/main/java/com/jeesite/common/utils/excel/ExcelImport.java b/common/src/main/java/com/jeesite/common/utils/excel/ExcelImport.java index e8da823c..6cf337d5 100644 --- a/common/src/main/java/com/jeesite/common/utils/excel/ExcelImport.java +++ b/common/src/main/java/com/jeesite/common/utils/excel/ExcelImport.java @@ -319,7 +319,7 @@ public class ExcelImport implements Closeable { * @param cls 导入对象类型 * @param groups 导入分组 */ - public List getDataList(Class cls, String... groups) throws InstantiationException, IllegalAccessException{ + public List getDataList(Class cls, String... groups) throws Exception{ return getDataList(cls, false, groups); } @@ -329,7 +329,7 @@ public class ExcelImport implements Closeable { * @param isThrowException 遇见错误是否抛出异常 * @param groups 导入分组 */ - public List getDataList(Class cls, final boolean isThrowException, String... groups) throws InstantiationException, IllegalAccessException{ + public List getDataList(Class cls, final boolean isThrowException, String... groups) throws Exception{ return getDataList(cls, new MethodCallback() { @Override public Object execute(Object... params) { @@ -350,7 +350,7 @@ public class ExcelImport implements Closeable { * @param groups 导入分组 */ @SuppressWarnings("unchecked") - public List getDataList(Class cls, MethodCallback exceptionCallback, String... groups) throws InstantiationException, IllegalAccessException{ + public List getDataList(Class cls, MethodCallback exceptionCallback, String... groups) throws Exception{ List annotationList = ListUtils.newArrayList(); // Get annotation field Field[] fs = cls.getDeclaredFields(); @@ -380,15 +380,15 @@ public class ExcelImport implements Closeable { Collections.sort(annotationList, new Comparator() { @Override public int compare(Object[] o1, Object[] o2) { - return new Integer(((ExcelField)o1[0]).sort()).compareTo( - new Integer(((ExcelField)o2[0]).sort())); + return Integer.valueOf(((ExcelField)o1[0]).sort()).compareTo( + Integer.valueOf(((ExcelField)o2[0]).sort())); }; }); //log.debug("Import column count:"+annotationList.size()); // Get excel data List dataList = ListUtils.newArrayList(); for (int i = this.getDataRowNum(); i < this.getLastDataRowNum(); i++) { - E e = (E)cls.newInstance(); + E e = (E)cls.getDeclaredConstructor().newInstance(); Row row = this.getRow(i); if (row == null){ continue; diff --git a/common/src/main/java/com/jeesite/common/web/http/ServletUtils.java b/common/src/main/java/com/jeesite/common/web/http/ServletUtils.java index be5d2820..f9277f17 100644 --- a/common/src/main/java/com/jeesite/common/web/http/ServletUtils.java +++ b/common/src/main/java/com/jeesite/common/web/http/ServletUtils.java @@ -213,7 +213,7 @@ public class ServletUtils { return XmlMapper.toXml(resultMap); }else{ if (response != null){ - response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE); + response.setContentType(MediaType.APPLICATION_JSON_VALUE); } if (ObjectUtils.toBoolean(PropertiesUtils.getInstance().getProperty("web.jsonp.enabled"))) { String functionName = request.getParameter("__callback"); @@ -225,7 +225,7 @@ public class ServletUtils { } }else{ if (response != null){ - response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE); + response.setContentType(MediaType.APPLICATION_JSON_VALUE); } return JsonMapper.toJson(resultMap); } @@ -300,7 +300,7 @@ public class ServletUtils { if (type == null && StringUtils.isBlank(response.getContentType())){ if ((StringUtils.startsWith(string, "{") && StringUtils.endsWith(string, "}")) || (StringUtils.startsWith(string, "[") && StringUtils.endsWith(string, "]"))){ - type = MediaType.APPLICATION_JSON_UTF8_VALUE; + type = MediaType.APPLICATION_JSON_VALUE; }else if (StringUtils.startsWith(string, "<") && StringUtils.endsWith(string, ">")){ if (StringUtils.startsWith(string, " shiroFilterProxy(ShiroFilterFactoryBean shiroFilter) throws Exception { - if (Global.isUseCorpModel() != Global.getPropertyToBoolean("user.useCorpModel", "false")){ - throw new Exception("\n\nuser.useCorpModel=true? 你是否开启了多租户模式?视乎你的当前版本不是JeeSite专业版。\n"); - } FilterRegistrationBean bean = new FilterRegistrationBean<>(); bean.setFilter((Filter) shiroFilter.getInstance()); bean.addUrlPatterns("/*"); diff --git a/modules/core/src/main/java/com/jeesite/modules/sys/service/support/EmpUserServiceSupport.java b/modules/core/src/main/java/com/jeesite/modules/sys/service/support/EmpUserServiceSupport.java index 408cf3af..91f4e36f 100644 --- a/modules/core/src/main/java/com/jeesite/modules/sys/service/support/EmpUserServiceSupport.java +++ b/modules/core/src/main/java/com/jeesite/modules/sys/service/support/EmpUserServiceSupport.java @@ -5,6 +5,7 @@ package com.jeesite.modules.sys.service.support; import java.util.List; +import javax.annotation.PostConstruct; import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolationException; @@ -48,6 +49,16 @@ public class EmpUserServiceSupport extends CrudService @Autowired private EmployeeOfficeDao employeeOfficeDao; + /** + * 租户功能验证 + */ + @PostConstruct + private void corpModelValid() throws Exception{ + if (Global.isUseCorpModel() != Global.getPropertyToBoolean("user.useCorpModel", "false")){ + throw new Exception("\n\nuser.useCorpModel=true? 你开启了多租户模式,视乎你的当前版本不是JeeSite专业版。\n"); + } + } + /** * 获取单条数据 */ diff --git a/parent/pom.xml b/parent/pom.xml index a2210705..474c7527 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -42,6 +42,7 @@ 3.4.0 4.1.2 2.5.1 + 3.0.2 3.5.4 diff --git a/web/src/main/resources/config/j2cache.properties b/web/src/main/resources/config/j2cache.properties index 42b46574..d4d68aee 100644 --- a/web/src/main/resources/config/j2cache.properties +++ b/web/src/main/resources/config/j2cache.properties @@ -1,20 +1,5 @@ #J2Cache configuration -######################################### -# Cache Broadcast Method -# values: -# redis -> use redis publish/subscribe mechanism (using jedis) -# lettuce -> use redis publish/subscribe mechanism (using lettuce) -# jgroups -> use jgroups's multicast -# rabbitmq -> use RabbitMQ publisher/consumer mechanism -# rocketmq -> use RocketMQ publisher/consumer mechanism -# none -> don't notify the other nodes in cluster -# xx.xxxx.xxxx.Xxxxx your own cache broadcast policy classname that implement net.oschina.j2cache.cluster.ClusterPolicy -######################################### - -#j2cache.broadcast = redis -j2cache.broadcast = com.jeesite.common.j2cache.cache.support.redis.SpringRedisPubSubPolicy - ######################################### # Cache Clean Mode # active -> 主动清除,二级缓存过期主动通知各节点清除,优点在于所有节点可以同时收到缓存清除 @@ -24,47 +9,6 @@ j2cache.broadcast = com.jeesite.common.j2cache.cache.support.redis.SpringRedisPu j2cache.broadcast.cache_clean_mode = passive -######################################### -# Level 1&2 provider -# values: -# none -> disable this level cache -# ehcache -> use ehcache2 as level 1 cache -# ehcache3 -> use ehcache3 as level 1 cache -# caffeine -> use caffeine as level 1 cache(only in memory) -# redis -> use redis as level 2 cache (using jedis) -# lettuce -> use redis as level 2 cache (using lettuce) -# readonly-redis -> use redis as level 2 cache ,but never write data to it. if use this provider, you must uncomment `j2cache.L2.config_section` to make the redis configurations available. -# memcached -> use memcached as level 2 cache (xmemcached), -# [classname] -> use custom provider -######################################### - -j2cache.L1.provider_class = caffeine -#j2cache.L2.provider_class = redis -j2cache.L2.provider_class = com.jeesite.common.j2cache.cache.support.redis.SpringRedisProvider - -# When L2 provider isn't `redis`, using `L2.config_section = redis` to read redis configurations -j2cache.L2.config_section = redis - -# Enable/Disable ttl in redis cache data (if disabled, the object in redis will never expire, default:true) -# NOTICE: redis hash mode (redis.storage = hash) do not support this feature) -j2cache.sync_ttl_to_redis = true - -# Whether to cache null objects by default (default false) -j2cache.default_cache_null_object = true - -######################################### -# Cache Serialization Provider -# values: -# fst -> using fast-serialization (recommend) -# kyro -> using kyro serialization -# json -> using fst's json serialization (testing) -# fastjson -> using fastjson serialization (embed non-static class not support) -# java -> java standard -# [classname implements Serializer] -######################################### - -j2cache.serialization = fst - ######################################### # Caffeine configuration # caffeine.region.[cacheName] = size, xxxx[s|m|h|d] @@ -83,8 +27,6 @@ redis.storage = hash ## redis pub/sub channel name redis.channel = j2cache -## redis pub/sub server (using redis.hosts when empty) -redis.channel.host = ## redis cache namespace optional, default[j2cache] redis.namespace = jeesite