Mybitis根据工具类反射数据库生成映射+整合springboot
一 反向生成数据库mapper的工具类:
添加依赖
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<scope>test</scope>
<version>1.3.2</version>
<optional>true</optional>
</dependency> <dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency> <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
工具类
package org.mybatis.generator.plugins; import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.PluginAdapter;
import org.mybatis.generator.api.dom.java.*;
import org.mybatis.generator.api.dom.xml.Attribute;
import org.mybatis.generator.api.dom.xml.TextElement;
import org.mybatis.generator.api.dom.xml.XmlElement; import java.util.List; public class AddLimitOffsetPlugin extends PluginAdapter { public boolean validate(List<String> warnings) {
return true;
} public boolean modelExampleClassGenerated(TopLevelClass topLevelClass,
IntrospectedTable introspectedTable) {
FullyQualifiedJavaType offsetType = new FullyQualifiedJavaType(
"javax.annotation.Generated");
topLevelClass.addImportedType(offsetType);
topLevelClass.addAnnotation("@Generated(\"" + introspectedTable.getTableConfiguration().getTableName() + "\")");
PrimitiveTypeWrapper integerWrapper = FullyQualifiedJavaType.getIntInstance().getPrimitiveTypeWrapper(); Field limit = new Field();
limit.setName("limit");
limit.setVisibility(JavaVisibility.PRIVATE);
limit.setType(integerWrapper);
topLevelClass.addField(limit); Method limitSet = new Method();
limitSet.setVisibility(JavaVisibility.PUBLIC);
limitSet.setName("setLimit");
limitSet.addParameter(new Parameter(integerWrapper, "limit"));
limitSet.addBodyLine("this.limit = limit;");
topLevelClass.addMethod(limitSet); Method limitGet = new Method();
limitGet.setVisibility(JavaVisibility.PUBLIC);
limitGet.setReturnType(integerWrapper);
limitGet.setName("getLimit");
limitGet.addBodyLine("return limit;");
topLevelClass.addMethod(limitGet); Field offset = new Field();
offset.setName("offset");
offset.setVisibility(JavaVisibility.PRIVATE);
offset.setType(integerWrapper);
topLevelClass.addField(offset); Method offsetSet = new Method();
offsetSet.setVisibility(JavaVisibility.PUBLIC);
offsetSet.setName("setOffset");
offsetSet.addParameter(new Parameter(integerWrapper, "offset"));
offsetSet.addBodyLine("this.offset = offset;");
topLevelClass.addMethod(offsetSet); Method offsetGet = new Method();
offsetGet.setVisibility(JavaVisibility.PUBLIC);
offsetGet.setReturnType(integerWrapper);
offsetGet.setName("getOffset");
offsetGet.addBodyLine("return offset;");
topLevelClass.addMethod(offsetGet); return true;
} public boolean sqlMapSelectByExampleWithoutBLOBsElementGenerated(
XmlElement element, IntrospectedTable introspectedTable) {
XmlElement isNotNullElement = new XmlElement("if");
isNotNullElement.addAttribute(new Attribute("test", "limit > 0"));
isNotNullElement.addElement(new TextElement("limit ${limit}"));
element.getElements().add(isNotNullElement); isNotNullElement = new XmlElement("if");
isNotNullElement.addAttribute(new Attribute("test", "offset > 0"));
isNotNullElement.addElement(new TextElement("offset ${offset}"));
element.getElements().add(isNotNullElement);
return true;
} }
package org.mybatis.generator.plugins; import org.apache.commons.io.IOUtils;
import org.junit.Test;
import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.api.ProgressCallback;
import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.config.Context;
import org.mybatis.generator.config.xml.ConfigurationParser;
import org.mybatis.generator.internal.DefaultShellCallback; import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern; /**
* mybatis代码生成插件调用者.
*/
public class Generator { @Test
public void generate() throws Exception {
List<String> warnings = new ArrayList<String>();
boolean overwrite = true; InputStream stream = Generator.class.getClassLoader().getResourceAsStream("generatorConfig.xml"); ConfigurationParser cp = new ConfigurationParser(warnings);
InputStreamReader reader = new InputStreamReader(stream, "utf-8");
BufferedReader bufferedReader = new BufferedReader(reader); String line = bufferedReader.readLine();
StringBuffer buffer = new StringBuffer();
while (line != null) {
buffer.append(line + "\n");
line = bufferedReader.readLine();
}
String xmlWithParam = buffer.toString(); System.out.println("------- xml config begin -------");
System.out.println(xmlWithParam);
System.out.println("------- xml config end -------"); final Configuration config = cp.parseConfiguration(new ByteArrayInputStream(xmlWithParam.getBytes("utf-8")));
DefaultShellCallback callback = new DefaultShellCallback(overwrite);
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
System.out.println("------- generator begin -------");
ProgressCallback cb = new ProgressCallback() {
private Pattern SqlProviderPattern = Pattern.compile("\\w*SqlProvider\\.java");
private List<String> taskNames = new ArrayList(); @Override
public void startTask(String taskName) {
/*
* 输出这些信息从而知道 生成那些类了
* Generating Example class for table demo
* Generating Primary Key class for table demo
* Generating Record class for table demo
* Generating Mapper Interface for table demo
* Generating SQL Provider for table demo
* Saving file DemoExample.java
* Saving file DemoKey.java Saving file Demo.java
* Saving file DemoMapper.java
* Saving file DemoSqlProvider.java
*/
// System.out.println(taskName);
taskNames.add( taskName);
} @Override
public void saveStarted(int arg0) {} @Override
public void introspectionStarted(int arg0) {} @Override
public void generationStarted(int arg0) {} @Override
public void done() {
for(String taskName : taskNames){
Matcher matcher = SqlProviderPattern.matcher(taskName);
if (matcher.find()) {
final String SqlProviderFilename = matcher.group();
System.out.println("处理生成文件,selectByExample 增加mysql分页: " + SqlProviderFilename);
List<Context> contexts = config.getContexts();
FilenameFilter filter = new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return SqlProviderFilename.equalsIgnoreCase(name);
}
};
boolean done = false;
for (Context ctx : contexts) {
if(done){
break;
}
String targetProject = ctx.getJavaClientGeneratorConfiguration().getTargetProject();
String targetPackage = ctx.getJavaClientGeneratorConfiguration().getTargetPackage();
String dir = targetProject.replaceAll("\\.", "\\\\") + "\\" + targetPackage.replaceAll("\\.", "\\\\");
System.out.println(System.getProperty("user.dir") + dir);
File mapperDir = new File(System.getProperty("user.dir"), dir);
File[] files = mapperDir.listFiles(filter);
if (files != null && files.length > 0) {
File sqlProviderFile = files[0];
try {
Generator.addMysqlLimit(sqlProviderFile);
done = true;
} catch (Exception e) {
e.printStackTrace();
}
}
}
if(!done){
System.out.println("转换失败!!!! selectByExample 增加mysql分页: " + SqlProviderFilename);
} else {
System.out.println("转换成功!!!! selectByExample 增加mysql分页: " + SqlProviderFilename);
}
}
}
} @Override
public void checkCancel() throws InterruptedException {}
};
myBatisGenerator.generate(cb);
for (String warning : warnings) {
System.out.println(warning);
}
System.out.println("------- generator end -------");
// System.out.println(config.getClassPathEntries());
} private static void addMysqlLimit(File sqlProviderFile) throws Exception {
/*
* 这是自动生成的selectByExample 中的代码片段
if (example != null && example.getOrderByClause() != null) {
ORDER_BY(example.getOrderByClause()); // 整个文件唯一
} return SQL(); * 将return SQL()改为下面片段即可: String sqlString = SQL();
if (example != null && example.getLimit() != null) {
sqlString += " limit " + example.getLimit();
}
if (example != null && example.getOffset() != null) {
sqlString += " offset " + example.getOffset();
}
return sqlString;
*/
BufferedReader reader = new BufferedReader( new FileReader(sqlProviderFile));
List<String> lines = IOUtils.readLines(reader);
reader.close();
String limitString = " String sqlString = SQL();\n" +
" if (example != null && example.getLimit() != null) {\n" +
" sqlString += \" limit \" + example.getLimit();\n" +
" }\n" +
" if (example != null && example.getOffset() != null) {\n" +
" sqlString += \" offset \" + example.getOffset();\n" +
" }\n" +
" return sqlString;";
ArrayList<String> newLines = new ArrayList<String>(); for (int i=0; i< lines.size();++i) {
String line = lines.get(i);
newLines.add(line );
if(line.replaceAll(" ", "") .equalsIgnoreCase("ORDER_BY(example.getOrderByClause());")) {
// 添加下一行大括号和空白行
++i;
newLines.add(lines.get(i));
++i;
newLines.add(lines.get(i)); ++i; // 跳过 return SQL();
newLines.addAll(Arrays.asList( limitString.split("\n")));
}
} // for (String line : newLines) {
// System.out.println(line);
// }
FileOutputStream writer = new FileOutputStream(sqlProviderFile);
IOUtils.writeLines(newLines, "\n",writer,"UTF-8");
writer.close();
} public static void main(String[] args) throws Exception {
new Generator().generate();
}
}
映射关系配置xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
<generatorConfiguration> <context id="entmobile" targetRuntime="MyBatis3"> <plugin type="org.mybatis.generator.plugins.AddLimitOffsetPlugin" />
<plugin type="org.mybatis.generator.plugins.ToStringPlugin" /> <commentGenerator>
<property name="suppressDate" value="true" />
<!-- remove comments -->
<property name="suppressAllComments" value="true" />
</commentGenerator> <jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/demo?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC"
userId="root" password="root" /> <!-- java type resolver -->
<javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver> <!-- gem entity -->
<!-- data -->
<javaModelGenerator targetPackage="com.自己建的实体类包.domain"
targetProject="./src/main/java">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="false" />
</javaModelGenerator> <!-- //////////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
<!-- gem annotated mapper -->
<!-- data -->
<javaClientGenerator type="ANNOTATEDMAPPER"
targetPackage="com.自己建的mapper包.mapper"
targetProject="./src/main/java">
<property name="enableSubPackages" value="true" />
</javaClientGenerator> <!--
<table tableName="material_type">
<generatedKey column="id" sqlStatement="JDBC"/>
</table>
--> <table tableName="表名">
<generatedKey column="id" sqlStatement="JDBC"/>
</table> </context>
</generatorConfiguration>
另外springboot启动类中添加注解:
@EnableAutoConfiguration
二 数据库配置 application.yml:
spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/demo?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&connectTimeout=3000&socketTimeout=1000
username: root # 自己修改填写
password: root # 自己修改填写
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver
minIdle: 5
maxActive: 100
initialSize: 10
maxWait: 60000
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: select 'x'
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 50
removeAbandoned: true
filters: stat # ,wall,log4j # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 # 通过connectProperties属性来打开mergeSql功能;慢SQL记录
useGlobalDataSourceStat: true # 合并多个DruidDataSource的监控数据
druidLoginName: wjf # 登录druid的账号
druidPassword: wjf # 登录druid的密码
cachePrepStmts: true # 开启二级缓存
redis:
database: 0
host: XX.XX.XX.XX
port: 6380
password: 1234567
activemq:
broker-url: tcp://XX.XX.XX.XX:61616
user: admin
password: zhangjiawen
pool:
enabled: true
max-connections: 100
mybatis:
typeAliasesPackage: com.concurrent.mapper # 自己修改填写
mapperLocations: classpath:/com/concurrent/mapper/*.xml
mapperScanPackage: com.concurrent.mapper
configLocation: classpath:/mybatis-config.xml
mybatis-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<!-- 使全局的映射器启用或禁用缓存。 -->
<setting name="cacheEnabled" value="true" />
<!-- 全局启用或禁用延迟加载。当禁用时,所有关联对象都会即时加载。 -->
<setting name="lazyLoadingEnabled" value="true" />
<!-- 当启用时,有延迟加载属性的对象在被调用时将会完全加载任意属性。否则,每种属性将会按需要加载。 -->
<setting name="aggressiveLazyLoading" value="true"/>
<!-- 是否允许单条sql 返回多个数据集 (取决于驱动的兼容性) default:true -->
<setting name="multipleResultSetsEnabled" value="true" />
<!-- 是否可以使用列的别名 (取决于驱动的兼容性) default:true -->
<setting name="useColumnLabel" value="true" />
<!-- 允许JDBC 生成主键。需要驱动器支持。如果设为了true,这个设置将强制使用被生成的主键,有一些驱动器不兼容不过仍然可以执行。 default:false -->
<setting name="useGeneratedKeys" value="false" />
<!-- 指定 MyBatis 如何自动映射 数据基表的列 NONE:不隐射 PARTIAL:部分 FULL:全部 -->
<setting name="autoMappingBehavior" value="PARTIAL" />
<!-- 这是默认的执行类型 (SIMPLE: 简单; REUSE: 执行器可能重复使用prepared statements语句;BATCH: 执行器可以重复执行语句和批量更新) -->
<setting name="defaultExecutorType" value="SIMPLE" /> <setting name="defaultStatementTimeout" value="25" /> <setting name="defaultFetchSize" value="100" /> <setting name="safeRowBoundsEnabled" value="false" />
<!-- 使用驼峰命名法转换字段。 -->
<setting name="mapUnderscoreToCamelCase" value="true" />
<!-- 设置本地缓存范围 session:就会有数据的共享 statement:语句范围 (这样就不会有数据的共享 ) defalut:session -->
<setting name="localCacheScope" value="SESSION" />
<!-- 默认为OTHER,为了解决oracle插入null报错的问题要设置为NULL -->
<setting name="jdbcTypeForNull" value="NULL" />
<setting name="lazyLoadTriggerMethods" value="equals,clone,hashCode,toString" />
</settings> </configuration>
另外还有将mapper数据映射加入spring扫描
package com.concurrent.service; import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.support.http.StatViewServlet;
import com.alibaba.druid.support.http.WebStatFilter;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession; import javax.sql.DataSource;
import java.sql.SQLException; /**
* Created on 2016/10/25 0025.
*/ @Configuration
@MapperScan("com.自己建的映射包.mapper")
@EnableRedisHttpSession(maxInactiveIntervalInSeconds= 50)
public class DataSourceConfig {
private Logger logger = LoggerFactory.getLogger(DataSourceConfig.class); @Value("${spring.datasource.url}")
private String dbUrl; @Value("${spring.datasource.type}")
private String dbType; @Value("${spring.datasource.username}")
private String username; @Value("${spring.datasource.password}")
private String password; @Value("${spring.datasource.driver-class-name}")
private String driverClassName; @Value("${spring.datasource.initialSize}")
private int initialSize; @Value("${spring.datasource.minIdle}")
private int minIdle; @Value("${spring.datasource.maxActive}")
private int maxActive; @Value("${spring.datasource.maxWait}")
private int maxWait; @Value("${spring.datasource.timeBetweenEvictionRunsMillis}")
private int timeBetweenEvictionRunsMillis; @Value("${spring.datasource.minEvictableIdleTimeMillis}")
private int minEvictableIdleTimeMillis; @Value("${spring.datasource.validationQuery}")
private String validationQuery; @Value("${spring.datasource.testWhileIdle}")
private boolean testWhileIdle; @Value("${spring.datasource.testOnBorrow}")
private boolean testOnBorrow; @Value("${spring.datasource.testOnReturn}")
private boolean testOnReturn; @Value("${spring.datasource.poolPreparedStatements}")
private boolean poolPreparedStatements; @Value("${spring.datasource.filters}")
private String filters; @Value("${spring.datasource.connectionProperties}")
private String connectionProperties; @Value("${spring.datasource.useGlobalDataSourceStat}")
private boolean useGlobalDataSourceStat; @Value("${spring.datasource.druidLoginName}")
private String druidLoginName; @Value("${spring.datasource.druidPassword}")
private String druidPassword; @Bean(name="dataSource",destroyMethod = "close", initMethod="init")
@Primary //不要漏了这
public DataSource dataSource(){
DruidDataSource datasource = new DruidDataSource();
try {
datasource.setUrl(this.dbUrl);
datasource.setDbType(dbType);
datasource.setUsername(username);
datasource.setPassword(password);
datasource.setDriverClassName(driverClassName);
datasource.setInitialSize(initialSize);
datasource.setMinIdle(minIdle);
datasource.setMaxActive(maxActive);
datasource.setMaxWait(maxWait);
datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
datasource.setValidationQuery(validationQuery);
datasource.setTestWhileIdle(testWhileIdle);
datasource.setTestOnBorrow(testOnBorrow);
datasource.setTestOnReturn(testOnReturn);
datasource.setPoolPreparedStatements(poolPreparedStatements);
datasource.setFilters(filters);
} catch (SQLException e) {
logger.error("druid configuration initialization filter", e);
}
return datasource;
} ///////// 下面是druid 监控访问的设置 /////////////////
@Bean
public ServletRegistrationBean druidServlet() {
ServletRegistrationBean reg = new ServletRegistrationBean();
reg.setServlet(new StatViewServlet());
reg.addUrlMappings("/druid/*"); //url 匹配
reg.addInitParameter("allow", "192.168.16.110,127.0.0.1"); // IP白名单 (没有配置或者为空,则允许所有访问)
reg.addInitParameter("deny", "192.168.16.111"); //IP黑名单 (存在共同时,deny优先于allow)
reg.addInitParameter("loginUsername", this.druidLoginName);//登录名
reg.addInitParameter("loginPassword", this.druidPassword);//登录密码
reg.addInitParameter("resetEnable", "false"); // 禁用HTML页面上的“Reset All”功能
return reg;
} @Bean(name="druidWebStatFilter")
public FilterRegistrationBean filterRegistrationBean() {
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
filterRegistrationBean.setFilter(new WebStatFilter());
filterRegistrationBean.addUrlPatterns("/*");
filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"); //忽略资源
filterRegistrationBean.addInitParameter("profileEnable", "true");
filterRegistrationBean.addInitParameter("principalCookieName", "USER_COOKIE");
filterRegistrationBean.addInitParameter("principalSessionName", "USER_SESSION");
return filterRegistrationBean;
}
}
使用例子:
@Resource
private SysUserMapper sysUserMapper; private BloomFilter<Integer> bf; /***
* PostConstruct 程序启动时候加载此方法
*/
@PostConstruct
public void initBloomFilter() {
SysUserExample sysUserExample = new SysUserExample();
List<SysUser> sysUserList = sysUserMapper.selectByExample(sysUserExample); }
Mybitis根据工具类反射数据库生成映射+整合springboot的更多相关文章
- Java的generator工具类,数据库生成实体类和映射文件
首先需要几个jar包: freemarker-2.3.23.jar log4j-1.2.16.jar mybatis-3.2.3.jar mybatis-generator-core-1.3.2.ja ...
- 03HibernateJAVA类与数据库表映射配置
HibernateJAVA类与数据库表映射配置
- 工具类之数据库工具类:DBUtil(採用反射机制)
常常操作数据库的码农们一定知道操作数据库是一项非常复杂的工作.它不仅要解决各种乱码的问题还要解决各种数据表的增删改查等的操作. 另外每次操作数据库都要用到数据库连接.运行SQL语句.关闭连接的操作.所 ...
- Hibernate - POJO 类和数据库的映射文件*.hbm.xml
POJO 类和关系数据库之间的映射可以用一个XML文档来定义. 通过 POJO 类的数据库映射文件,Hibernate可以理解持久化类和数据表之间的对应关系,也可以理解持久化类属性与数据库表列之间的对 ...
- Java常用工具类之数据库操作辅助类DBUtil.java
package com.qushida.util; import java.beans.BeanInfo; import java.beans.Introspector; import java.be ...
- JDBC工具类 访问数据库 增删改查CRUD的通用方法
1 package com.zmh.util; 2 3 import java.sql.*; 4 import java.util.ArrayList; 5 import java.util.Hash ...
- java工具类(三)之生成若干位随机数
java 生成若干位随机数的问题 在一次编程的过程中偶然碰到一个小问题,就是需要生成一个4位数的随机数,如果是一个不到4位大的数字,前面可以加0来显示.因为要求最后是一个4位的整数,不带小数点.当时就 ...
- C# 工具类之数据库链接
一.SQL Server 相关 /// <summary> /// 数据库的通用访问代码 /// 此类为抽象类, /// 不允许实例化,在应用时直接调用即可 /// </summa ...
- java最全的获取某个接口或者某个类所有对应的所有实现类和继承类的工具类--反射动态获取、非动态获取、按照路径获取等总结
我们直接上代码吧,代码中有注释说明. //直接看代码吧 import java.io.File; import java.lang.reflect.Field; import java.net.URL ...
随机推荐
- 三种存储方式DAS、NAS、SAN
------------恢复内容开始------------ 一.DAS.NAS.SAN在存储领域的位置 随着主机.磁盘.网络等技术的发展,数据存储的方式和架构也在一直不停改变,本文主要介绍目前主流的 ...
- 机器学习实战基础(十二):sklearn中的数据预处理和特征工程(五) 数据预处理 Preprocessing & Impute 之 处理分类特征:处理连续性特征 二值化与分段
处理连续性特征 二值化与分段 sklearn.preprocessing.Binarizer根据阈值将数据二值化(将特征值设置为0或1),用于处理连续型变量.大于阈值的值映射为1,而小于或等于阈值的值 ...
- Flask 基础组件(六):Session
除请求对象之外,还有一个 session 对象.它允许你在不同请求间存储特定用户的信息.它是在 Cookies 的基础上实现的,并且对 Cookies 进行密钥签名要使用会话,你需要设置一个密钥. 设 ...
- 数据可视化之DAX篇(二十八)Power BI时间序列分析用到的度量值,一次全给你
https://zhuanlan.zhihu.com/p/88528732 在各种经营分析报告中,我们常常会看到YTD,YOY这样的统计指标,这样的数据计算并不难,尤其是在PowerBI中,因为有时间 ...
- 安卓移动端line-height垂直居中出现偏移的解决方法
目前移动端在项目使用的rem,安卓手机上line-height属性,让它的值等于height,结果发现是不居中的. 出现此问题的原因是Android在排版计算的时候参考了primyfont字体的相关属 ...
- 自动生成和安装requirements.txt依赖
在查看别人的Python项目时,经常会看到一个requirements.txt文件,里面记录了当前程序的所有依赖包及其精确版本号.这个文件有点类似与Rails的Gemfile.其作用是用来在另一台PC ...
- Ubuntu14.04 安装VMware tools
Ubuntu14.04 安装VMware tools 方法一: 1. 在VMware 11(个人的测试环境为vm 11版本)下安装Ubuntu镜像:ubuntu-14.04.1-desktop-amd ...
- 量子点/钙钛矿 LED的研究概述
注:参考文献和文章尚在整理ing... 一 常用术语 1.外量子效率(External quantum efficiency,EQE) 这是LED最重要的参数,它的定义为: 因此,EQE越大,发射到外 ...
- Ethical Hacking - Web Penetration Testing(9)
SQL INJECTION Discovering SQLi in GET Inject by browser URL. Selecting Data From Database Change the ...
- Python Ethical Hacking - MODIFYING DATA IN HTTP LAYER(3)
Recalculating Content-Length: #!/usr/bin/env python import re from netfilterqueue import NetfilterQu ...