From f8419592ff96d01e29a37b626cf1e48e7e50a9b6 Mon Sep 17 00:00:00 2001 From: Mamba <928477320@qq.com> Date: Sun, 29 Sep 2019 15:27:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0redis=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=B1=BB=EF=BC=8C=E5=AE=8C=E6=88=90100%=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=82=AE=E4=BB=B6=E5=8F=91=E9=80=81=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=B1=BB=EF=BC=8C=E5=AE=8C=E6=88=9050%?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dev-common/pom.xml | 16 + .../java/com/dev/common/utils/RedisUtils.java | 539 ++++++++++++++++++ .../com/dev/common/utils/SendMailUtils.java | 115 ++++ dev-framework/pom.xml | 6 + .../com/dev/framework/config/RedisConfig.java | 56 ++ .../src/main/resources/application-dev.yml | 35 +- .../src/main/resources/application-prod.yml | 157 +++-- .../main/resources/static/fly/mods/index.js | 9 +- pom.xml | 9 + 9 files changed, 871 insertions(+), 71 deletions(-) create mode 100644 dev-common/src/main/java/com/dev/common/utils/RedisUtils.java create mode 100644 dev-common/src/main/java/com/dev/common/utils/SendMailUtils.java create mode 100644 dev-framework/src/main/java/com/dev/framework/config/RedisConfig.java diff --git a/dev-common/pom.xml b/dev-common/pom.xml index f39fbd7..28f425a 100644 --- a/dev-common/pom.xml +++ b/dev-common/pom.xml @@ -110,6 +110,22 @@ org.springframework.data spring-data-elasticsearch + + + + org.springframework.boot + spring-boot-starter-mail + + + + + org.springframework.boot + spring-boot-starter-data-redis + + + org.apache.commons + commons-pool2 + \ No newline at end of file diff --git a/dev-common/src/main/java/com/dev/common/utils/RedisUtils.java b/dev-common/src/main/java/com/dev/common/utils/RedisUtils.java new file mode 100644 index 0000000..278bf79 --- /dev/null +++ b/dev-common/src/main/java/com/dev/common/utils/RedisUtils.java @@ -0,0 +1,539 @@ +package com.dev.common.utils; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +/** + * @Classname RedisUtil + * @Description redis工具类 + * @Date 2019/9/24 18:08 + * @Created by SSL + */ +@Component +public class RedisUtils { + @Autowired + private static RedisTemplate redisTemplate; + + public RedisUtils(RedisTemplate redisTemplate) { + this.redisTemplate = redisTemplate; + } + + + /** + * 指定缓存失效时间 + * @param key 键 + * @param time 时间(秒) + * @return + */ + public static boolean expire(String key,long time){ + try { + if(time>0){ + redisTemplate.expire(key, time, TimeUnit.SECONDS); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 根据key 获取过期时间 + * @param key 键 不能为null + * @return 时间(秒) 返回0代表为永久有效 + */ + public static long getExpire(String key){ + return redisTemplate.getExpire(key,TimeUnit.SECONDS); + } + + /** + * 判断key是否存在 + * @param key 键 + * @return true 存在 false不存在 + */ + public static boolean hasKey(String key){ + try { + return redisTemplate.hasKey(key); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 删除缓存 + * @param key 可以传一个值 或多个 + */ + @SuppressWarnings("unchecked") + public static void del(String ... key){ + if(key!=null&&key.length>0){ + if(key.length==1){ + redisTemplate.delete(key[0]); + }else{ + redisTemplate.delete(CollectionUtils.arrayToList(key)); + } + } + } + + //============================String============================= + /** + * 普通缓存获取 + * @param key 键 + * @return 值 + */ + public static Object get(String key){ + return key==null?null:redisTemplate.opsForValue().get(key); + } + + /** + * 普通缓存放入 + * @param key 键 + * @param value 值 + * @return true成功 false失败 + */ + public static boolean set(String key,Object value) { + try { + redisTemplate.opsForValue().set(key, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 普通缓存放入并设置时间 + * @param key 键 + * @param value 值 + * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期 + * @return true成功 false 失败 + */ + public static boolean set(String key,Object value,long time){ + try { + if(time>0){ + redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS); + }else{ + set(key, value); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 递增 + * @param key 键 + * @param delta 要增加几(大于0) + * @return + */ + public static long incr(String key, long delta){ + if(delta<0){ + throw new RuntimeException("递增因子必须大于0"); + } + return redisTemplate.opsForValue().increment(key, delta); + } + + /** + * 递减 + * @param key 键 + * @param delta 要减少几(小于0) + * @return + */ + public static long decr(String key, long delta){ + if(delta<0){ + throw new RuntimeException("递减因子必须大于0"); + } + return redisTemplate.opsForValue().increment(key, -delta); + } + + //================================Map================================= + /** + * HashGet + * @param key 键 不能为null + * @param item 项 不能为null + * @return 值 + */ + public static Object hget(String key,String item){ + return redisTemplate.opsForHash().get(key, item); + } + + /** + * 获取hashKey对应的所有键值 + * @param key 键 + * @return 对应的多个键值 + */ + public static Map hmget(String key){ + return redisTemplate.opsForHash().entries(key); + } + + /** + * HashSet + * @param key 键 + * @param map 对应多个键值 + * @return true 成功 false 失败 + */ + public static boolean hmset(String key, Map map){ + try { + redisTemplate.opsForHash().putAll(key, map); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * HashSet 并设置时间 + * @param key 键 + * @param map 对应多个键值 + * @param time 时间(秒) + * @return true成功 false失败 + */ + public static boolean hmset(String key, Map map, long time){ + try { + redisTemplate.opsForHash().putAll(key, map); + if(time>0){ + expire(key, time); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 向一张hash表中放入数据,如果不存在将创建 + * @param key 键 + * @param item 项 + * @param value 值 + * @return true 成功 false失败 + */ + public static boolean hset(String key,String item,Object value) { + try { + redisTemplate.opsForHash().put(key, item, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 向一张hash表中放入数据,如果不存在将创建 + * @param key 键 + * @param item 项 + * @param value 值 + * @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间 + * @return true 成功 false失败 + */ + public static boolean hset(String key,String item,Object value,long time) { + try { + redisTemplate.opsForHash().put(key, item, value); + if(time>0){ + expire(key, time); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 删除hash表中的值 + * @param key 键 不能为null + * @param item 项 可以使多个 不能为null + */ + public static void hdel(String key, Object... item){ + redisTemplate.opsForHash().delete(key,item); + } + + /** + * 判断hash表中是否有该项的值 + * @param key 键 不能为null + * @param item 项 不能为null + * @return true 存在 false不存在 + */ + public static boolean hHasKey(String key, String item){ + return redisTemplate.opsForHash().hasKey(key, item); + } + + /** + * hash递增 如果不存在,就会创建一个 并把新增后的值返回 + * @param key 键 + * @param item 项 + * @param by 要增加几(大于0) + * @return + */ + public static double hincr(String key, String item,double by){ + return redisTemplate.opsForHash().increment(key, item, by); + } + + /** + * hash递减 + * @param key 键 + * @param item 项 + * @param by 要减少记(小于0) + * @return + */ + public static double hdecr(String key, String item,double by){ + return redisTemplate.opsForHash().increment(key, item,-by); + } + + //============================set============================= + /** + * 根据key获取Set中的所有值 + * @param key 键 + * @return + */ + public static Set sGet(String key){ + try { + return redisTemplate.opsForSet().members(key); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * 根据value从一个set中查询,是否存在 + * @param key 键 + * @param value 值 + * @return true 存在 false不存在 + */ + public static boolean sHasKey(String key,Object value){ + try { + return redisTemplate.opsForSet().isMember(key, value); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将数据放入set缓存 + * @param key 键 + * @param values 值 可以是多个 + * @return 成功个数 + */ + public static long sSet(String key, Object...values) { + try { + return redisTemplate.opsForSet().add(key, values); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 将set数据放入缓存 + * @param key 键 + * @param time 时间(秒) + * @param values 值 可以是多个 + * @return 成功个数 + */ + public static long sSetAndTime(String key,long time,Object...values) { + try { + Long count = redisTemplate.opsForSet().add(key, values); + if(time>0) { + expire(key, time); + } + return count; + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 获取set缓存的长度 + * @param key 键 + * @return + */ + public static long sGetSetSize(String key){ + try { + return redisTemplate.opsForSet().size(key); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 移除值为value的 + * @param key 键 + * @param values 值 可以是多个 + * @return 移除的个数 + */ + public static long setRemove(String key, Object ...values) { + try { + Long count = redisTemplate.opsForSet().remove(key, values); + return count; + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + //===============================list================================= + + /** + * 获取list缓存的内容 + * @param key 键 + * @param start 开始 + * @param end 结束 0 到 -1代表所有值 + * @return + */ + public static List lGet(String key, long start, long end){ + try { + return redisTemplate.opsForList().range(key, start, end); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * 获取list缓存的长度 + * @param key 键 + * @return + */ + public static long lGetListSize(String key){ + try { + return redisTemplate.opsForList().size(key); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 通过索引 获取list中的值 + * @param key 键 + * @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推 + * @return + */ + public static Object lGetIndex(String key,long index){ + try { + return redisTemplate.opsForList().index(key, index); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * 将list放入缓存 + * @param key 键 + * @param value 值 + * @return + */ + public static boolean lSet(String key, Object value) { + try { + redisTemplate.opsForList().rightPush(key, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将list放入缓存 + * @param key 键 + * @param value 值 + * @param time 时间(秒) + * @return + */ + public static boolean lSet(String key, Object value, long time) { + try { + redisTemplate.opsForList().rightPush(key, value); + if (time > 0) { + expire(key, time); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将list放入缓存 + * @param key 键 + * @param value 值 + * @return + */ + public static boolean lSet(String key, List value) { + try { + redisTemplate.opsForList().rightPushAll(key, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将list放入缓存 + * @param key 键 + * @param value 值 + * @param time 时间(秒) + * @return + */ + public static boolean lSet(String key, List value, long time) { + try { + redisTemplate.opsForList().rightPushAll(key, value); + if (time > 0) { + expire(key, time); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 根据索引修改list中的某条数据 + * @param key 键 + * @param index 索引 + * @param value 值 + * @return + */ + public static boolean lUpdateIndex(String key, long index,Object value) { + try { + redisTemplate.opsForList().set(key, index, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 移除N个值为value + * @param key 键 + * @param count 移除多少个 + * @param value 值 + * @return 移除的个数 + */ + public static long lRemove(String key,long count,Object value) { + try { + Long remove = redisTemplate.opsForList().remove(key, count, value); + return remove; + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } +} diff --git a/dev-common/src/main/java/com/dev/common/utils/SendMailUtils.java b/dev-common/src/main/java/com/dev/common/utils/SendMailUtils.java new file mode 100644 index 0000000..89735f3 --- /dev/null +++ b/dev-common/src/main/java/com/dev/common/utils/SendMailUtils.java @@ -0,0 +1,115 @@ +package com.dev.common.utils; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import javax.mail.*; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeMessage; +import java.security.Security; +import java.util.Date; +import java.util.Properties; + +/** + * @Classname SendMailUtils + * @Description 发送邮箱 + * @Date 2019/9/29 11:25 + * @Created by SSL + */ +@Component +public class SendMailUtils { + private static String FORGOT_URL = "http://localhost:8083"; + private static String GOOGLE_SMTP_HOST; + private static String GOOGLE_SMTP_PORT; + private static String GOOGLE_MAIL_USER; + private static String GOOGLE_MAIL_PASSWORD; + + @Value("${mail.google.host}") + public void setGoogleSmtpHost(String data) { + SendMailUtils.GOOGLE_SMTP_HOST = data; + } + + @Value("${mail.google.port}") + public void setGoogleSmtpPort(String data) { + SendMailUtils.GOOGLE_SMTP_PORT = data; + } + + @Value("${mail.google.user}") + public void setGoogleMailUser(String data) { + SendMailUtils.GOOGLE_MAIL_USER = data; + } + + @Value("${mail.google.pwd}") + public void setGoogleMailPassword(String data) { + SendMailUtils.GOOGLE_MAIL_PASSWORD = data; + } + + public static boolean sendForgotPwd(String toMail, String code) { + String title = "[dev开发社区] 找回密码验证"; + String content = "找回密码验证\n" + + "\n" + + "尊敬的"+toMail + ":\n" + + "这封信是由 dev开发社区 发送的。\n" + + "\n" + + "您收到这封邮件,是由于在 dev开发社区 进行了找回密码。如果您并没有访问过 dev开发社区,或没有进行上述操作,请忽 略这封邮件。您不需要退订或进行其他进一步的操作。\n" + + "\n" + + "\n" + + "----------------------------------------------------------------------\n" + + "找回密码说明\n" + + "----------------------------------------------------------------------\n" + + "\n" + + "您只需点击下面的链接即可激活您的帐号:\n" + + FORGOT_URL + code + "\n" + + "(如果上面不是链接形式,请将该地址手工粘贴到浏览器地址栏再访问)\n" + + "\n" + + "感谢您的访问,祝您使用愉快!\n" + + "\n" + + "此致\n" + + "dev开发社区。\n" + + "http://bbs.52codes.net/"; + return sendGoogleMail(toMail, title, content); + } + + + //发送谷歌邮件 + public static boolean sendGoogleMail(String toMail, String title, String content) { + //配置ssl + Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); + final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory"; + // 配置发送邮件的环境属性 + Properties props = System.getProperties(); + props.put("mail.debug", "true"); + props.put("mail.smtp.host", GOOGLE_SMTP_HOST); + props.put("mail.smtp.socketFactory.class", SSL_FACTORY); + props.put("mail.smtp.ssl.enable", "true"); + props.put("mail.smtp.port", GOOGLE_SMTP_PORT); + props.put("mail.smtp.socketFactory.port", GOOGLE_SMTP_PORT); + props.put("mail.smtp.auth", "true"); + // 构建授权信息,用于进行SMTP进行身份验证 + Session session = Session.getDefaultInstance(props, new Authenticator() { + protected PasswordAuthentication getPasswordAuthentication() { + // 用户名、密码 + return new PasswordAuthentication(GOOGLE_MAIL_USER, GOOGLE_MAIL_PASSWORD); + } + }); + try { + // 创建邮件消息 + Message msg = new MimeMessage(session); + // 设置发件人邮件地址和名称。填写控制台配置的发信地址,比如xxx@xxx.com。和上面的mail.user保持一致。名称用户可以自定义填写。 + msg.setFrom(new InternetAddress(GOOGLE_MAIL_USER)); + // 设置收件人邮件地址,比如yyy@yyy.com + msg.setRecipients(Message.RecipientType.TO, + InternetAddress.parse(toMail, false)); + // 设置邮件标题 + msg.setSubject(title); + // 设置邮件的内容体 + msg.setText(content); + msg.setSentDate(new Date()); + Transport.send(msg); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + return true; + } +} diff --git a/dev-framework/pom.xml b/dev-framework/pom.xml index 04019c0..2914758 100644 --- a/dev-framework/pom.xml +++ b/dev-framework/pom.xml @@ -98,6 +98,12 @@ spring-boot-configuration-processor true + + + + org.springframework.boot + spring-boot-starter-data-redis + \ No newline at end of file diff --git a/dev-framework/src/main/java/com/dev/framework/config/RedisConfig.java b/dev-framework/src/main/java/com/dev/framework/config/RedisConfig.java new file mode 100644 index 0000000..03cf1e7 --- /dev/null +++ b/dev-framework/src/main/java/com/dev/framework/config/RedisConfig.java @@ -0,0 +1,56 @@ +package com.dev.framework.config; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.PropertyAccessor; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.cache.annotation.CachingConfigurerSupport; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; +import org.springframework.data.redis.serializer.StringRedisSerializer; + +/** + * @Classname RedisConfig + * @Description redis配置 + * @Date 2019/9/29 15:08 + * @Created by SSL + */ +@Configuration +public class RedisConfig extends CachingConfigurerSupport { + /** + * retemplate相关配置 + * @param factory + * @return + */ + @Bean + public RedisTemplate redisTemplate(RedisConnectionFactory factory) { + + RedisTemplate template = new RedisTemplate<>(); + // 配置连接工厂 + template.setConnectionFactory(factory); + + //使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值(默认使用JDK的序列化方式) + Jackson2JsonRedisSerializer jacksonSerializer = new Jackson2JsonRedisSerializer(Object.class); + + ObjectMapper om = new ObjectMapper(); + // 指定要序列化的域,field,get和set,以及修饰符范围,ANY是都有包括private和public + om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); + // 指定序列化输入的类型,类必须是非final修饰的,final修饰的类,比如String,Integer等会跑出异常 + om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); + jacksonSerializer.setObjectMapper(om); + + // 值采用json序列化 + template.setValueSerializer(jacksonSerializer); + //使用StringRedisSerializer来序列化和反序列化redis的key值 + template.setKeySerializer(new StringRedisSerializer()); + + // 设置hash key 和value序列化模式 + template.setHashKeySerializer(new StringRedisSerializer()); + template.setHashValueSerializer(jacksonSerializer); + template.afterPropertiesSet(); + + return template; + } +} diff --git a/dev-web/dev-web-bbs/src/main/resources/application-dev.yml b/dev-web/dev-web-bbs/src/main/resources/application-dev.yml index 8446b22..0fec4bd 100644 --- a/dev-web/dev-web-bbs/src/main/resources/application-dev.yml +++ b/dev-web/dev-web-bbs/src/main/resources/application-dev.yml @@ -57,4 +57,37 @@ spring: cluster-name: my-application cluster-nodes: 127.0.0.1:9300 repositories: - enabled: true \ No newline at end of file + enabled: true +#==================== redis ============================ + redis: + #数据库索引 + database: 0 + host: 192.168.5.58 + port: 6379 + password: yibayi_181~jishubu*007 + lettuce: + pool: + #最大连接数 + max-active: 8 + #最大阻塞等待时间(负数表示没限制) + max-wait: -1ms + #最大空闲 + max-idle: 8 + #最小空闲 + min-idle: 0 + #连接超时时间 + timeout: 10000ms + cache: + type: redis + servlet: + multipart: + max-file-size: 100MB + max-request-size: 100MB + +#==================== 自定义参数 ============================ +mail: + google: + host: smtp.gmail.com + port: 465 + user: ruoyidev@gmail.com + pwd: Hello.123 \ No newline at end of file diff --git a/dev-web/dev-web-bbs/src/main/resources/application-prod.yml b/dev-web/dev-web-bbs/src/main/resources/application-prod.yml index 2bd4939..23190e0 100644 --- a/dev-web/dev-web-bbs/src/main/resources/application-prod.yml +++ b/dev-web/dev-web-bbs/src/main/resources/application-prod.yml @@ -1,68 +1,101 @@ # 生产环境配置 server: - # 服务端口 - port: 8088 - # 下面2项配置结合nginx防止重定向到http,若无https需求可移除 - use-forward-headers: true - tomcat: - protocol-header: X-Forwarded-Proto + # 服务端口 + port: 8088 + # 下面2项配置结合nginx防止重定向到http,若无https需求可移除 + use-forward-headers: true + tomcat: + protocol-header: X-Forwarded-Proto ruoyi: - profile: /home/upload/ruoyi + profile: /home/upload/ruoyi # 数据源配置 spring: - datasource: - type: com.alibaba.druid.pool.DruidDataSource - driverClassName: com.mysql.cj.jdbc.Driver - druid: - # 主库数据源 - master: - url: jdbc:mysql://localhost:3306/dev?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - username: root - password: CBFTzjo0@X&uoB^Q - # 从库数据源 - slave: - # 从数据源开关/默认关闭 - enabled: false - url: - username: - password: - # 初始连接数 - initialSize: 5 - # 最小连接池数量 - minIdle: 10 - # 最大连接池数量 - maxActive: 20 - # 配置获取连接等待超时的时间 - maxWait: 60000 - # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 - timeBetweenEvictionRunsMillis: 60000 - # 配置一个连接在池中最小生存的时间,单位是毫秒 - minEvictableIdleTimeMillis: 300000 - # 配置一个连接在池中最大生存的时间,单位是毫秒 - maxEvictableIdleTimeMillis: 900000 - # 配置检测连接是否有效 - validationQuery: SELECT 1 FROM DUAL - testWhileIdle: true - testOnBorrow: false - testOnReturn: false - webStatFilter: - enabled: true - statViewServlet: - enabled: true - # 设置白名单,不填则允许所有访问 - allow: - url-pattern: /druid/* - # 控制台管理用户名和密码 - login-username: - login-password: - filter: - stat: - enabled: true - # 慢SQL记录 - log-slow-sql: true - slow-sql-millis: 1000 - merge-sql: true - wall: - config: - multi-statement-allow: true \ No newline at end of file + datasource: + type: com.alibaba.druid.pool.DruidDataSource + driverClassName: com.mysql.cj.jdbc.Driver + druid: + # 主库数据源 + master: + url: jdbc:mysql://localhost:3306/dev?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: root + password: CBFTzjo0@X&uoB^Q + # 从库数据源 + slave: + # 从数据源开关/默认关闭 + enabled: false + url: + username: + password: + # 初始连接数 + initialSize: 5 + # 最小连接池数量 + minIdle: 10 + # 最大连接池数量 + maxActive: 20 + # 配置获取连接等待超时的时间 + maxWait: 60000 + # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 + timeBetweenEvictionRunsMillis: 60000 + # 配置一个连接在池中最小生存的时间,单位是毫秒 + minEvictableIdleTimeMillis: 300000 + # 配置一个连接在池中最大生存的时间,单位是毫秒 + maxEvictableIdleTimeMillis: 900000 + # 配置检测连接是否有效 + validationQuery: SELECT 1 FROM DUAL + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + webStatFilter: + enabled: true + statViewServlet: + enabled: true + # 设置白名单,不填则允许所有访问 + allow: + url-pattern: /druid/* + # 控制台管理用户名和密码 + login-username: + login-password: + filter: + stat: + enabled: true + # 慢SQL记录 + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + wall: + config: + multi-statement-allow: true + #==================== redis ============================ + redis: + #数据库索引 + database: 0 + host: 192.168.5.58 + port: 6379 + password: yibayi_181~jishubu*007 + lettuce: + pool: + #最大连接数 + max-active: 8 + #最大阻塞等待时间(负数表示没限制) + max-wait: -1ms + #最大空闲 + max-idle: 8 + #最小空闲 + min-idle: 0 + #连接超时时间 + timeout: 10000ms + cache: + type: redis + servlet: + multipart: + max-file-size: 100MB + max-request-size: 100MB + +#==================== 自定义参数 ============================ +mail: + google: + host: smtp.gmail.com + port: 465 + user: ruoyidev@gmail.com + pwd: Hello.123 \ No newline at end of file diff --git a/dev-web/dev-web-bbs/src/main/resources/static/fly/mods/index.js b/dev-web/dev-web-bbs/src/main/resources/static/fly/mods/index.js index 40ba6d4..f40d829 100644 --- a/dev-web/dev-web-bbs/src/main/resources/static/fly/mods/index.js +++ b/dev-web/dev-web-bbs/src/main/resources/static/fly/mods/index.js @@ -1,11 +1,4 @@ -/** - - @Name: Fly社区主入口 - - */ - - -layui.define(['layer', 'laytpl', 'form', 'element', 'upload', 'util'], function(exports){ +layui.define(['layer', 'laytpl', 'form', 'element', 'upload', 'util'], function(exports){ var $ = layui.jquery ,layer = layui.layer diff --git a/pom.xml b/pom.xml index fce08cd..4b462b6 100644 --- a/pom.xml +++ b/pom.xml @@ -38,6 +38,7 @@ 1.2.49 6.5.1 3.1.4.RELEASE + 2.6.2 @@ -218,6 +219,7 @@ ${mapper.starter.version} + org.elasticsearch.client transport @@ -234,6 +236,13 @@ spring-data-elasticsearch ${spring.es.version} + + + + org.apache.commons + commons-pool2 + ${common.pool.version} + -- Gitee