重新配置下数据源,防止druid检测失败

This commit is contained in:
hupeng committed 2019-09-11 17:38:36 +08:00
1 parent eb4e6a3e49
commit 8a1e515b94
16 files changed
+715 -23

No files matched your search

+7 -2
View File
@@ -27,7 +27,7 @@
<kaptcha.version>2.3.2</kaptcha.version>
<ehcache.version>3.3.1</ehcache.version>
<zxing.version>3.2.1</zxing.version>
<druid.version>1.1.10</druid.version>
<druid.version>1.1.14</druid.version>
<beetl.version>2.8.5</beetl.version>
<swagger.version>2.9.2</swagger.version>
<commons-lang3.version>3.7</commons-lang3.version>
@@ -98,9 +98,14 @@
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.alibaba</groupId>-->
<!-- <artifactId>druid</artifactId>-->
<!-- <version>${druid.version}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${druid.version}</version>
</dependency>
<dependency>
@@ -0,0 +1,103 @@
package com.ruoyi.app.common.config;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties;
import com.alibaba.druid.util.Utils;
import com.ruoyi.app.common.config.properties.DruidProperties;
//import com.ruoyi.common.enums.DataSourceType;
//import com.ruoyi.framework.datasource.DynamicDataSource;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import javax.servlet.*;
import javax.sql.DataSource;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
* druid 配置多数据源
*
* @author ruoyi
*/
@Configuration
public class DruidConfig
{
@Bean
@ConfigurationProperties("spring.datasource.druid.master")
public DataSource masterDataSource(DruidProperties druidProperties)
{
DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
return druidProperties.dataSource(dataSource);
}
@Bean
@ConfigurationProperties("spring.datasource.druid.slave")
@ConditionalOnProperty(prefix = "spring.datasource.druid.slave", name = "enabled", havingValue = "true")
public DataSource slaveDataSource(DruidProperties druidProperties)
{
DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
return druidProperties.dataSource(dataSource);
}
// @Bean(name = "dynamicDataSource")
// @Primary
// public DynamicDataSource dataSource(DataSource masterDataSource, DataSource slaveDataSource)
// {
// Map<Object, Object> targetDataSources = new HashMap<>();
// targetDataSources.put(DataSourceType.MASTER.name(), masterDataSource);
// targetDataSources.put(DataSourceType.SLAVE.name(), slaveDataSource);
// return new DynamicDataSource(masterDataSource, targetDataSources);
// }
/**
* 去除监控页面底部的广告
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Bean
@ConditionalOnProperty(name = "spring.datasource.druid.statViewServlet.enabled", havingValue = "true")
public FilterRegistrationBean removeDruidFilterRegistrationBean(DruidStatProperties properties)
{
// 获取web监控页面的参数
DruidStatProperties.StatViewServlet config = properties.getStatViewServlet();
// 提取common.js的配置路径
String pattern = config.getUrlPattern() != null ? config.getUrlPattern() : "/druid/*";
String commonJsPattern = pattern.replaceAll("\\*", "js/common.js");
final String filePath = "support/http/resources/js/common.js";
// 创建filter进行过滤
Filter filter = new Filter()
{
@Override
public void init(javax.servlet.FilterConfig filterConfig) throws ServletException
{
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException
{
chain.doFilter(request, response);
// 重置缓冲区,响应头不会被重置
response.resetBuffer();
// 获取common.js
String text = Utils.readFromResource(filePath);
// 正则替换banner, 除去底部的广告信息
text = text.replaceAll("<a.*?banner\"></a><br/>", "");
text = text.replaceAll("powered.*?shrek.wang</a>", "");
response.getWriter().write(text);
}
@Override
public void destroy()
{
}
};
FilterRegistrationBean registrationBean = new FilterRegistrationBean();
registrationBean.setFilter(filter);
registrationBean.addUrlPatterns(commonJsPattern);
return registrationBean;
}
}
@@ -0,0 +1,77 @@
package com.ruoyi.app.common.config.properties;
import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
/**
* druid 配置属性
*
* @author ruoyi
*/
@Configuration
public class DruidProperties
{
@Value("${spring.datasource.druid.initialSize}")
private int initialSize;
@Value("${spring.datasource.druid.minIdle}")
private int minIdle;
@Value("${spring.datasource.druid.maxActive}")
private int maxActive;
@Value("${spring.datasource.druid.maxWait}")
private int maxWait;
@Value("${spring.datasource.druid.timeBetweenEvictionRunsMillis}")
private int timeBetweenEvictionRunsMillis;
@Value("${spring.datasource.druid.minEvictableIdleTimeMillis}")
private int minEvictableIdleTimeMillis;
@Value("${spring.datasource.druid.maxEvictableIdleTimeMillis}")
private int maxEvictableIdleTimeMillis;
@Value("${spring.datasource.druid.validationQuery}")
private String validationQuery;
@Value("${spring.datasource.druid.testWhileIdle}")
private boolean testWhileIdle;
@Value("${spring.datasource.druid.testOnBorrow}")
private boolean testOnBorrow;
@Value("${spring.datasource.druid.testOnReturn}")
private boolean testOnReturn;
public DruidDataSource dataSource(DruidDataSource datasource)
{
/** 配置初始化大小、最小、最大 */
datasource.setInitialSize(initialSize);
datasource.setMaxActive(maxActive);
datasource.setMinIdle(minIdle);
/** 配置获取连接等待超时的时间 */
datasource.setMaxWait(maxWait);
/** 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 */
datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
/** 配置一个连接在池中最小、最大生存的时间,单位是毫秒 */
datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
datasource.setMaxEvictableIdleTimeMillis(maxEvictableIdleTimeMillis);
/**
* 用来检测连接是否有效的sql,要求是一个查询语句,常用select 'x'。如果validationQuery为null,testOnBorrow、testOnReturn、testWhileIdle都不会起作用。
*/
datasource.setValidationQuery(validationQuery);
/** 建议配置为true,不影响性能,并且保证安全性。申请连接的时候检测,如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效。 */
datasource.setTestWhileIdle(testWhileIdle);
/** 申请连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。 */
datasource.setTestOnBorrow(testOnBorrow);
/** 归还连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。 */
datasource.setTestOnReturn(testOnReturn);
return datasource;
}
}
@@ -0,0 +1,17 @@
package com.ruoyi.app.common.persistence.dao;
import com.ruoyi.app.common.persistence.model.StoreCart;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 购物车表 Mapper 接口
* </p>
*
* @author hupeng
* @since 2019-09-10
*/
public interface StoreCartMapper extends BaseMapper<StoreCart> {
}
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.app.common.persistence.dao.StoreCartMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.ruoyi.app.common.persistence.model.StoreCart">
<id column="id" property="id" />
<result column="user_id" property="userId" />
<result column="session_id" property="sessionId" />
<result column="goods_id" property="goodsId" />
<result column="goods_sn" property="goodsSn" />
<result column="goods_name" property="goodsName" />
<result column="market_price" property="marketPrice" />
<result column="goods_price" property="goodsPrice" />
<result column="member_goods_price" property="memberGoodsPrice" />
<result column="goods_num" property="goodsNum" />
<result column="spec_key" property="specKey" />
<result column="spec_key_name" property="specKeyName" />
<result column="bar_code" property="barCode" />
<result column="selected" property="selected" />
<result column="add_time" property="addTime" />
<result column="prom_type" property="promType" />
<result column="prom_id" property="promId" />
<result column="sku" property="sku" />
</resultMap>
</mapper>
@@ -27,18 +27,27 @@ public class StoreAds extends Model<StoreAds> {
*/
@TableField("video_url")
private String videoUrl;
/**
* 轮播图片地址
*/
private String url;
/**
* 类型1-视频 2-图片
*/
private Integer type;
/**
* 序号
*/
private Integer sort;
/**
* 创建时间
*/
@@ -0,0 +1,287 @@
package com.ruoyi.app.common.persistence.model;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import javax.xml.crypto.Data;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 购物车表
* </p>
*
* @author hupeng
* @since 2019-09-10
*/
@TableName("store_cart")
public class StoreCart extends Model<StoreCart> {
private static final long serialVersionUID = 1L;
/**
* 购物车表
*/
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/**
* 用户id
*/
@TableField("user_id")
private Integer userId;
/**
* session
*/
@TableField("session_id")
private String sessionId;
/**
* 商品id
*/
@TableField("goods_id")
private Integer goodsId;
/**
* 商品货号
*/
@TableField("goods_sn")
private String goodsSn;
/**
* 商品名称
*/
@TableField("goods_name")
private String goodsName;
/**
* 零售价
*/
@TableField("market_price")
private BigDecimal marketPrice;
/**
* 本店价(进货价)
*/
@TableField("goods_price")
private BigDecimal goodsPrice;
/**
* 会员折扣价
*/
@TableField("member_goods_price")
private BigDecimal memberGoodsPrice;
/**
* 购买数量
*/
@TableField("goods_num")
private Integer goodsNum;
/**
* 商品规格key 对应store_spec_goods_price 表
*/
@TableField("spec_key")
private String specKey;
/**
* 商品规格组合名称
*/
@TableField("spec_key_name")
private String specKeyName;
/**
* 商品条码
*/
@TableField("bar_code")
private String barCode;
/**
* 购物车选中状态
*/
private Integer selected;
/**
* 加入购物车的时间
*/
@TableField(value = "add_time",fill = FieldFill.INSERT)
private Date addTime;
/**
* 0 普通订单,1 限时抢购, 2 团购 , 3 促销优惠
*/
@TableField("prom_type")
private Integer promType;
/**
* 活动id
*/
@TableField("prom_id")
private Integer promId;
/**
* sku
*/
private String sku;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getSessionId() {
return sessionId;
}
public void setSessionId(String sessionId) {
this.sessionId = sessionId;
}
public Integer getGoodsId() {
return goodsId;
}
public void setGoodsId(Integer goodsId) {
this.goodsId = goodsId;
}
public String getGoodsSn() {
return goodsSn;
}
public void setGoodsSn(String goodsSn) {
this.goodsSn = goodsSn;
}
public String getGoodsName() {
return goodsName;
}
public void setGoodsName(String goodsName) {
this.goodsName = goodsName;
}
public BigDecimal getMarketPrice() {
return marketPrice;
}
public void setMarketPrice(BigDecimal marketPrice) {
this.marketPrice = marketPrice;
}
public BigDecimal getGoodsPrice() {
return goodsPrice;
}
public void setGoodsPrice(BigDecimal goodsPrice) {
this.goodsPrice = goodsPrice;
}
public BigDecimal getMemberGoodsPrice() {
return memberGoodsPrice;
}
public void setMemberGoodsPrice(BigDecimal memberGoodsPrice) {
this.memberGoodsPrice = memberGoodsPrice;
}
public Integer getGoodsNum() {
return goodsNum;
}
public void setGoodsNum(Integer goodsNum) {
this.goodsNum = goodsNum;
}
public String getSpecKey() {
return specKey;
}
public void setSpecKey(String specKey) {
this.specKey = specKey;
}
public String getSpecKeyName() {
return specKeyName;
}
public void setSpecKeyName(String specKeyName) {
this.specKeyName = specKeyName;
}
public String getBarCode() {
return barCode;
}
public void setBarCode(String barCode) {
this.barCode = barCode;
}
public Integer getSelected() {
return selected;
}
public void setSelected(Integer selected) {
this.selected = selected;
}
public Date getAddTime() {
return addTime;
}
public void setAddTime(Date addTime) {
this.addTime = addTime;
}
public Integer getPromType() {
return promType;
}
public void setPromType(Integer promType) {
this.promType = promType;
}
public Integer getPromId() {
return promId;
}
public void setPromId(Integer promId) {
this.promId = promId;
}
public String getSku() {
return sku;
}
public void setSku(String sku) {
this.sku = sku;
}
@Override
protected Serializable pkVal() {
return this.id;
}
@Override
public String toString() {
return "StoreCart{" +
", id=" + id +
", userId=" + userId +
", sessionId=" + sessionId +
", goodsId=" + goodsId +
", goodsSn=" + goodsSn +
", goodsName=" + goodsName +
", marketPrice=" + marketPrice +
", goodsPrice=" + goodsPrice +
", memberGoodsPrice=" + memberGoodsPrice +
", goodsNum=" + goodsNum +
", specKey=" + specKey +
", specKeyName=" + specKeyName +
", barCode=" + barCode +
", selected=" + selected +
", addTime=" + addTime +
", promType=" + promType +
", promId=" + promId +
", sku=" + sku +
"}";
}
}
@@ -10,6 +10,7 @@ import com.ruoyi.app.modular.shop.service.dto.SpecItemDTO;
import com.ruoyi.app.modular.shop.service.impl.CateServiceImpl;
import com.ruoyi.app.modular.shop.service.impl.GoodsServiceImpl;
import com.ruoyi.app.modular.shop.service.mapper.GoodsMapper;
import com.ruoyi.app.modular.shop.service.vo.CartVO;
import com.ruoyi.app.modular.shop.service.vo.CollectVO;
import com.ruoyi.app.modular.shop.service.vo.PageVO;
import io.swagger.annotations.Api;
@@ -113,4 +114,17 @@ public class MallController {
}
}
@PostMapping("/shop/mall-add-cart")
@ApiOperation(value = "添加购物车",notes = "添加购物车")
public R addCart(@Validated @RequestBody CartVO cartVO){
int userId = userOperator.getUser().getId();
boolean result = goodsService.addCart(cartVO,userId);
if(result){
return R.success("操作成功");
}else{
return R.error(4000,"操作失败");
}
}
}
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.app.common.persistence.model.StoreGoods;
import com.ruoyi.app.common.persistence.model.StoreSpecGoodsPrice;
import com.ruoyi.app.modular.shop.service.dto.GoodsDTO;
import com.ruoyi.app.modular.shop.service.vo.CartVO;
import java.util.List;
import java.util.Map;
@@ -23,4 +24,6 @@ public interface IGoodsService extends IService<StoreGoods> {
public Map<String,StoreSpecGoodsPrice> goodsSpecPrice(int goodsId);
public boolean addOrCancelCollect(int goodsId,int userId,int type);
public boolean addCart(CartVO cartVO,int userId);
}
@@ -0,0 +1,25 @@
package com.ruoyi.app.modular.shop.service.dto;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
public class CartDTO implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
private String goodsName;
private BigDecimal goodsPrice;
private Integer goodsNum;
private String specKeyName;
}
@@ -11,9 +11,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itmuch.lightsecurity.exception.LightSecurityException;
import com.ruoyi.app.common.exception.BadRequestException;
import com.ruoyi.app.common.persistence.dao.StoreCartMapper;
import com.ruoyi.app.common.persistence.dao.StoreGoodsCollectMapper;
import com.ruoyi.app.common.persistence.dao.StoreGoodsMapper;
import com.ruoyi.app.common.persistence.dao.StoreSpecGoodsPriceMapper;
import com.ruoyi.app.common.persistence.model.StoreCart;
import com.ruoyi.app.common.persistence.model.StoreGoods;
import com.ruoyi.app.common.persistence.model.StoreGoodsCollect;
import com.ruoyi.app.common.persistence.model.StoreSpecGoodsPrice;
@@ -21,15 +23,15 @@ import com.ruoyi.app.modular.shop.service.IGoodsService;
import com.ruoyi.app.modular.shop.service.dto.GoodsDTO;
import com.ruoyi.app.modular.shop.service.dto.ItemDTO;
import com.ruoyi.app.modular.shop.service.dto.SpecItemDTO;
import com.ruoyi.app.modular.shop.service.mapper.CateMapper;
import com.ruoyi.app.modular.shop.service.mapper.GoodsMapper;
import com.ruoyi.app.modular.shop.service.vo.CartAttrVO;
import com.ruoyi.app.modular.shop.service.vo.CartVO;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
@@ -41,6 +43,7 @@ public class GoodsServiceImpl extends ServiceImpl<StoreGoodsMapper, StoreGoods>
private final StoreGoodsMapper storeGoodsMapper;
private final StoreGoodsCollectMapper storeGoodsCollectMapper;
private final StoreSpecGoodsPriceMapper storeSpecGoodsPriceMapper;
private final StoreCartMapper storeCartMapper;
/**
@@ -167,4 +170,43 @@ public class GoodsServiceImpl extends ServiceImpl<StoreGoodsMapper, StoreGoods>
return false;
}
}
@Override
public boolean addCart(CartVO cartVO,int userId) {
StoreGoods storeGoods = getById(cartVO.getGoodsId());
for (CartAttrVO attrVO : cartVO.getCartAttr()) {
QueryWrapper<StoreSpecGoodsPrice> wrapper = new QueryWrapper<>();
QueryWrapper<StoreCart> cartQueryWrapper = new QueryWrapper<>();
wrapper.eq("goods_id",cartVO.getGoodsId()).eq("`key`",attrVO.getSpecKey());
StoreSpecGoodsPrice storeSpecGoodsPrice = storeSpecGoodsPriceMapper
.selectOne(wrapper);
cartQueryWrapper.eq("goods_id",cartVO.getGoodsId())
.eq("user_id",userId).eq("spec_key",attrVO.getSpecKey());
StoreCart storeCart = storeCartMapper.selectOne(cartQueryWrapper);
if(storeCart != null){
storeCart.setGoodsNum(attrVO.getGoodsNum());
storeCartMapper.updateById(storeCart);
continue;
}
StoreCart cart = new StoreCart();
cart.setGoodsNum(attrVO.getGoodsNum());
cart.setGoodsPrice(storeSpecGoodsPrice.getPrice());
cart.setGoodsId(storeGoods.getGoodsId());
cart.setUserId(userId);
cart.setGoodsSn(storeGoods.getGoodsSn());
cart.setGoodsName(storeGoods.getGoodsName());
cart.setSpecKey(attrVO.getSpecKey());
cart.setSpecKeyName(storeSpecGoodsPrice.getKeyName());
int result = storeCartMapper.insert(cart);
if(result == 0) return false;
}
return true;
}
}
@@ -0,0 +1,18 @@
package com.ruoyi.app.modular.shop.service.mapper;
import com.ruoyi.app.common.persistence.model.StoreCart;
import com.ruoyi.app.modular.mapper.EntityMapper;
import com.ruoyi.app.modular.shop.service.dto.CartDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author hupeng
* @date 2019-09-10
*/
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface CartMapper extends EntityMapper<CartDTO, StoreCart> {
}
@@ -0,0 +1,18 @@
package com.ruoyi.app.modular.shop.service.vo;
import lombok.Data;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
@Data
public class CartAttrVO {
private String specKey;
private int goodsNum;
}
@@ -0,0 +1,15 @@
package com.ruoyi.app.modular.shop.service.vo;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.util.List;
@Data
public class CartVO {
@NotBlank(message = "goodsId必传")
private String goodsId;
private List<CartAttrVO> cartAttr;
}
+48 -16
View File
@@ -37,40 +37,72 @@ mybatis-plus:
mapper-locations: classpath*:com/ruoyi/app/common/persistence/dao/mapping/*.xml
typeAliasesPackage: com.ruoyi.app.common.persistence.model
global-config:
id-type: 0 #0:数据库ID自增 1:用户输入id 2:全局唯一id(IdWorker) 3:全局唯一ID(uuid)
db-column-underline: false
refresh-mapper: true
configuration:
map-underscore-to-camel-case: false
cache-enabled: true #配置的缓存的全局开关
lazyLoadingEnabled: true #延时加载的开关
multipleResultSetsEnabled: true #开启的话,延时加载一个属性时会加载该对象全部属性,否则按需加载属性
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #打印sql语句,调试用
banner: false
db-config:
# 主键类型 0:数据库ID自增 1.未定义 2.用户输入 3 id_worker 4.uuid 5.id_worker字符串表示
id-type: AUTO
#字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
field-strategy: NOT_NULL
# 默认数据库表下划线命名
table-underline: true
# configuration:
# map-underscore-to-camel-case: false
# cache-enabled: true #配置的缓存的全局开关
# lazyLoadingEnabled: true #延时加载的开关
# multipleResultSetsEnabled: true #开启的话,延时加载一个属性时会加载该对象全部属性,否则按需加载属性
## log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #打印sql语句,调试用
spring:
#DATABASE CONFIG
datasource:
#driver-class-name: com.mysql.jdbc.Driver
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
#driverClassName: com.mysql.cj.jdbc.Driver
username: root
password: root
url: jdbc:p6spy:mysql://localhost:3306/ruoyi?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=UTC
#url: jdbc:mysql://localhost:3306/ruoyi?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=UTC
type: com.alibaba.druid.pool.DruidDataSource #这里是配置druid连接池,以下都是druid的配置信息
filters: stat,wall,log4j
druid:
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 10
# 最大连接池数量
maxActive: 20
initialSize: 1
# 配置获取连接等待超时的时间
maxWait: 60000
minIdle: 1
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
validationQuery: select 'x'
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
testWhileIdle: true
validationQuery: SELECT 1 FROM DUAL
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
maxOpenPreparedStatements: 20
connection-properties: druid.stat.merggSql=ture;druid.stat.slowSqlMillis=5000
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
@@ -58,7 +58,7 @@ public class EntityGenerator {
StrategyConfig strategy = new StrategyConfig();
//strategy.setTablePrefix(new String[]{"_"});// 此处可以修改为您的表前缀
strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
strategy.setInclude(new String[]{"store_goods_cate"});
strategy.setInclude(new String[]{"store_cart"});
mpg.setStrategy(strategy);
// 包配置