spring boot +mybatis+druid 多数据源配置
因为我的工程需要在两个数据库中操作数据,所以要配置两个数据库,我这里没有数据源没有什么主从之分,只是配合多数据源必须要指定一个主数据源,所以我就把
操作相对要对的那个数据库设置为主数据(dataBase1 库)源
数据源配置
###################本地应用配置#################
spring:
application:
name: test
datasource:
url:
dataBase1: jdbc:mysql://192.168.666666.66:3306/dataBase1
dataBase2: jdbc:mysql://192.168.66666.67:3306/dataBase2?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true
username:
dataBase1: dataBase1
dataBase2: dataBase2
password:
dataBase1: dataBase1
dataBase2: dataBase2
driver: com.mysql.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
initialSize: 5
minIdle: 5
maxActive: 20
maxWait: 10000
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: true
testOnReturn: false
poolPreparedStatements: true
maxOpenPreparedStatementConnectionSize: 20
filters: stat,wall,log4j
connectionProperties: druid.stat.mergeSql:true;druid.stat.slowSqlMillis:5000
数据源抽象类(因为数据库的配置属性太多了,所以把通用的数据放到这个抽象类中,默认的配置也是主数据源)
package so.dian.device.common.config; import java.sql.SQLException; import javax.sql.DataSource; 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.Configuration; import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.support.http.StatViewServlet;
import com.alibaba.druid.support.http.WebStatFilter; @Configuration
public abstract class AbstractDBConfig { private static Logger log = LoggerFactory.getLogger(AbstractDBConfig.class); private String driver; private String url; private String username; private String password; private int maxActive; private int maxWait; private int initialSize; private int minEvictableIdleTimeMillis; private int minIdle; private String validationQuery; private boolean testWhileIdle; private boolean testOnBorrow; private boolean testOnReturn; private String connectionProperties; private String filters; private long timeBetweenEvictionRunsMillis; private boolean poolPreparedStatements; private int maxOpenPreparedStatementConnectionSize; private String mapperLocations; @Value("${maxOpenPreparedStatementConnectionSize}")
public int getMaxOpenPreparedStatementConnectionSize() {
return maxOpenPreparedStatementConnectionSize;
} public void setMaxOpenPreparedStatementConnectionSize(int maxOpenPreparedStatementConnectionSize) {
this.maxOpenPreparedStatementConnectionSize = maxOpenPreparedStatementConnectionSize;
} public String getMapperLocations() {
return mapperLocations;
} @Value("${mybatis.configuration.mapper-locations.dataBase1}")
public void setMapperLocations(String mapperLocations) {
this.mapperLocations = mapperLocations;
} public String getFilters() {
return filters;
} public String getDriver() {
return driver;
} @Value("${spring.datasource.driver}")
public void setDriver(String driver) {
this.driver = driver;
} public String getUrl() {
return url;
} @Value("${spring.datasource.url.dataBase1}")
public void setUrl(String url) {
this.url = url;
} public String getUsername() {
return username;
} @Value("${spring.datasource.username.dataBase1}")
public void setUsername(String username) {
this.username = username;
} public String getPassword() {
return password;
} @Value("${spring.datasource.password.dataBase1}")
public void setPassword(String password) {
this.password = password;
} public int getMaxActive() {
return maxActive;
} @Value("${spring.datasource.maxActive}")
public void setMaxActive(int maxActive) {
this.maxActive = maxActive;
} public int getMaxWait() {
return maxWait;
} @Value("${spring.datasource.maxWait}")
public void setMaxWait(int maxWait) {
this.maxWait = maxWait;
} public int getInitialSize() {
return initialSize;
} @Value("${spring.datasource.initialSize}")
public void setInitialSize(int initialSize) {
this.initialSize = initialSize;
} public int getMinEvictableIdleTimeMillis() {
return minEvictableIdleTimeMillis;
} @Value("${spring.datasource.minEvictableIdleTimeMillis}")
public void setMinEvictableIdleTimeMillis(int minEvictableIdleTimeMillis) {
this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
} public int getMinIdle() {
return minIdle;
} @Value("${spring.datasource.minIdle}")
public void setMinIdle(int minIdle) {
this.minIdle = minIdle;
} public String getValidationQuery() {
return validationQuery;
} @Value("${spring.datasource.validationQuery}")
public void setValidationQuery(String validationQuery) {
this.validationQuery = validationQuery;
} public boolean isTestWhileIdle() {
return testWhileIdle;
} @Value("${spring.datasource.testWhileIdle}")
public void setTestWhileIdle(boolean testWhileIdle) {
this.testWhileIdle = testWhileIdle;
} public boolean isTestOnBorrow() {
return testOnBorrow;
} @Value("${spring.datasource.testOnBorrow}")
public void setTestOnBorrow(boolean testOnBorrow) {
this.testOnBorrow = testOnBorrow;
} public boolean isTestOnReturn() {
return testOnReturn;
} @Value("${spring.datasource.testOnReturn}")
public void setTestOnReturn(boolean testOnReturn) {
this.testOnReturn = testOnReturn;
} public String getConnectionProperties() {
return connectionProperties;
} @Value("${spring.datasource.connectionProperties}")
public void setConnectionProperties(String connectionProperties) {
this.connectionProperties = connectionProperties;
} @Value("${spring.datasource.filters}")
public void setFilters(String filters) {
this.filters = filters;
} public long getTimeBetweenEvictionRunsMillis() {
return timeBetweenEvictionRunsMillis;
} @Value("${spring.datasource.timeBetweenEvictionRunsMillis}")
public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) {
this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
} public boolean isPoolPreparedStatements() {
return poolPreparedStatements;
} @Value("${spring.datasource.poolPreparedStatements}")
public void setPoolPreparedStatements(boolean poolPreparedStatements) {
this.poolPreparedStatements = poolPreparedStatements;
} public int getmaxOpenPreparedStatementConnectionSize() {
return maxOpenPreparedStatementConnectionSize;
} @Value("${spring.datasource.maxOpenPreparedStatementConnectionSize}")
public void setmaxOpenPreparedStatementConnectionSize(int maxOpenPreparedStatementConnectionSize) {
this.maxOpenPreparedStatementConnectionSize = maxOpenPreparedStatementConnectionSize;
} /**
* AbstractDBConfig.java
* @Description:自定义数据源
* @return
* @throws Exception
* @date 2018年1月22日 下午5:26:25
* @author ningque
*
*/
public abstract DataSource dataSource()throws Exception;
/**
*
* AbstractDBConfig.java
* @Description:自定义事物
* @return
* @throws Exception
* @date 2018年1月22日 下午5:26:38
* @author ningque
*
*/
public abstract DataSourceTransactionManager transactionManager()throws Exception;
/**
*
* AbstractDBConfig.java
* @Description:自定义session
* @param dataSource
* @return
* @throws Exception
* @date 2018年1月22日 下午5:27:41
* @author ningque
*
*/
public abstract SqlSessionFactory sqlSessionFactory( DataSource dataSource)throws Exception;
/**
*
* AbstractDBConfig.java
* @Description:配置druid 监控
* @return
* @date 2018年1月22日 下午5:28:01
* @author ningque
*
*/
public abstract ServletRegistrationBean druidServlet();
public abstract FilterRegistrationBean filterRegistrationBean();
}
主数据源类
package so.dian.device.common.config; import java.sql.SQLException; import javax.sql.DataSource; import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager; import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.support.http.StatViewServlet;
import com.alibaba.druid.support.http.WebStatFilter; @Configuration
@ConfigurationProperties(prefix = "spring.datasource")
@MapperScan(basePackages="so.dian.device.dao.dataBase1",sqlSessionFactoryRef = "dataBase1SqlSessionFactory")
public class dataBase1DruidDBConfig extends AbstractDBConfig { private static Logger log = LoggerFactory.getLogger(dataBase1DruidDBConfig.class); private String url;
private String mapperLocations;
public String userName;
public String passWord;
private String typeAliasesPackage; public String getTypeAliasesPackage() {
return typeAliasesPackage;
} @Value("${mybatis.type-aliases-package.dataBase1}")
public void setTypeAliasesPackage(String typeAliasesPackage) {
this.typeAliasesPackage = typeAliasesPackage;
} public String getUserName() {
return userName;
} @Value("${spring.datasource.username.dataBase1}")
public void setUserName(String userName) {
this.userName = userName;
} public String getPassWord() {
return passWord;
} @Value("${spring.datasource.password.dataBase1}")
public void setPassWord(String passWord) {
this.passWord = passWord;
} public String getUrl() {
return url;
} @Value("${spring.datasource.url.dataBase1}")
public void setUrl(String url) {
this.url = url;
} public String getMapperLocations() {
return mapperLocations;
} @Value("${mybatis.mapper-locations.dataBase1}")
public void setMapperLocations(String mapperLocations) {
this.mapperLocations = mapperLocations;
} @Bean(name = "dataBase1DataSource")
@Primary
public DataSource dataSource() throws SQLException {
log.info("---------------开始初始化 dataBase1DataSource!!");
DruidDataSource druidDataSource = new DruidDataSource();
log.info("driver -->:" + getDriver() + ", url -->:" + url);
druidDataSource.setDriverClassName(getDriver());
druidDataSource.setUrl(getUrl());
druidDataSource.setUsername(getUsername());
druidDataSource.setPassword(getPassword()); druidDataSource.setMaxActive(getMaxActive());
druidDataSource.setInitialSize(getInitialSize());
druidDataSource.setMinIdle(getMinIdle());
druidDataSource.setMaxWait(getMaxWait());
druidDataSource.setMinEvictableIdleTimeMillis(getMinEvictableIdleTimeMillis());
druidDataSource.setValidationQuery(getValidationQuery());
druidDataSource.setTestWhileIdle(isTestWhileIdle());
druidDataSource.setTestOnBorrow(isTestOnBorrow());
druidDataSource.setTestOnReturn(isTestOnReturn());
druidDataSource.setConnectionProperties(getConnectionProperties());
druidDataSource.setFilters(getFilters());
druidDataSource.setTimeBetweenEvictionRunsMillis(getTimeBetweenEvictionRunsMillis());
druidDataSource.setPoolPreparedStatements(isPoolPreparedStatements());
druidDataSource.setMaxOpenPreparedStatements(getMaxOpenPreparedStatementConnectionSize());
return druidDataSource;
} @Bean(name = "dataBase1TransactionManager")
@Primary
public DataSourceTransactionManager transactionManager()throws Exception {
return new DataSourceTransactionManager(dataBase1PrimaryDataSource());
} @Bean(name = "dataBase1SqlSessionFactory")
@Primary
public SqlSessionFactory sqlSessionFactory(@Qualifier("dataBase1DataSource") DataSource dataBase1DataSource)
throws Exception {
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(dataBase1DataSource);
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(getMapperLocations()));
sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
return sessionFactory.getObject();
} @Bean
@RefreshScope
public ServletRegistrationBean druidServlet() {
log.info("---------------开始初始化 ServletRegistrationBean!!");
ServletRegistrationBean reg = new ServletRegistrationBean();
reg.setServlet(new StatViewServlet());
reg.addUrlMappings("/druid/*");
reg.addInitParameter("loginUsername", "hello");
reg.addInitParameter("loginPassword", "hello123");
return reg;
} @Bean
@RefreshScope
public FilterRegistrationBean filterRegistrationBean() {
log.info("---------------开始初始化 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;
} }
从数据源配置
package so.dian.device.common.config; import java.sql.SQLException; import javax.sql.DataSource; import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.dataBase2.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager; import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.support.http.StatViewServlet;
import com.alibaba.druid.support.http.WebStatFilter; @Configuration
@ConfigurationProperties(prefix = "spring.datasource")
@MapperScan(basePackages="so.dian.device.dao.dataBase2",sqlSessionFactoryRef = "dataBase2SqlSessionFactory")
public classdataBase2DruidDBConfig extends AbstractDBConfig { private static Logger log = LoggerFactory.getLogger(dataBase2DruidDBConfig.class); private String url;
public String userName;
public String passWord;
private String mapperLocations;
private String typeAliasesPackage; public String getTypeAliasesPackage() {
return typeAliasesPackage;
} @Value("${mybatis.type-aliases-package.dataBase2}")
public void setTypeAliasesPackage(String typeAliasesPackage) {
this.typeAliasesPackage = typeAliasesPackage;
} public String getUserName() {
return userName;
} @Value("${spring.datasource.username.dataBase2}")
public void setUserName(String userName) {
this.userName = userName;
} public String getPassWord() {
return passWord;
} @Value("${spring.datasource.password.dataBase2}")
public void setPassWord(String passWord) {
this.passWord = passWord;
} public String getUrl() {
return url;
} @Value("${spring.datasource.url.dataBase2}")
public void setUrl(String url) {
this.url = url;
} public String getMapperLocations() {
return mapperLocations;
} @Value("${mybatis.mapper-locations.dataBase2}")
public void setMapperLocations(String mapperLocations) {
this.mapperLocations = mapperLocations;
} @Bean(name = "dataBase2DataSource")
public DataSourcedataBase2 dataSource() throws SQLException {
log.info("---------------开始初始化dataBase2DataSource!!");
DruidDataSource druidDataSource = new DruidDataSource();
log.info("driver -->:" + getDriver() + ", url -->:" + url);
druidDataSource.setDriverClassName(getDriver());
druidDataSource.setUrl(url);
druidDataSource.setUsername(userName);
druidDataSource.setPassword(passWord); druidDataSource.setMaxActive(getMaxActive());
druidDataSource.setInitialSize(getInitialSize());
druidDataSource.setMinIdle(getMinIdle());
druidDataSource.setMaxWait(getMaxWait());
druidDataSource.setMinEvictableIdleTimeMillis(getMinEvictableIdleTimeMillis());
druidDataSource.setValidationQuery(getValidationQuery());
druidDataSource.setTestWhileIdle(isTestWhileIdle());
druidDataSource.setTestOnBorrow(isTestOnBorrow());
druidDataSource.setTestOnReturn(isTestOnReturn());
druidDataSource.setConnectionProperties(getConnectionProperties());
druidDataSource.setFilters(getFilters());
druidDataSource.setTimeBetweenEvictionRunsMillis(getTimeBetweenEvictionRunsMillis());
druidDataSource.setPoolPreparedStatements(isPoolPreparedStatements());
druidDataSource.setMaxOpenPreparedStatements(getMaxOpenPreparedStatementConnectionSize());
return druidDataSource;
} @Bean(name = "dataBase2TransactionManager")
public DataSourceTransactionManager transactionManager()throws Exception {
return new DataSourceTransactionManager(dataBase2DataSource());
} @Bean(name = "dataBase2SqlSessionFactory")
public SqlSessionFactory sqlSessionFactory(@Qualifier("dataBase2DataSource") DataSource dataBase2DataSource)
throws Exception {
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(dataBase2DataSource);
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(mapperLocations));
sessionFactory.setTypeAliasesPackage(getTypeAliasesPackage());
return sessionFactory.getObject();
} @Bean
@RefreshScope
public ServletRegistrationBean druidServlet() {
log.info("---------------开始初始化 ServletRegistrationBean!!");
ServletRegistrationBean reg = new ServletRegistrationBean();
reg.setServlet(new StatViewServlet());
reg.addUrlMappings("/druid/*");
reg.addInitParameter("loginUsername", "fac");
reg.addInitParameter("loginPassword", "r5bk2fey");
return reg;
} @Bean
@RefreshScope
public FilterRegistrationBean filterRegistrationBean() {
log.info("---------------开始初始化 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;
}
}
ok 启动工程
[INFO] - ---------------开始初始化 dataBase1DataSource!!
2018-01-22 16:48:34.830 [main] [config.DataBase1DruidDBConfig.dataBase1PrimaryDataSource] [INFO] - driver -->:com.mysql.jdbc.Driver, url -->:jdbc:mysql://192.168.166.66:3306/dataBase1
2018-01-22 16:48:36.462 [main] [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$3.doWith] [WARN] - Autowired annotation should only be used on methods with parameters: public int config.AbstractDBConfig.getMaxOpenPreparedStatementConnectionSize()
2018-01-22 16:48:36.541 [main] [config.DataBase1DruidDBConfig.dataBase1DataSource] [INFO] - ---------------开始初始化 dataBase2DataSource!!
2018-01-22 16:48:36.542 [main] [config.DataBase2DruidDBConfig.dataBase2DataSource] [INFO] - driver -->:com.mysql.jdbc.Driver, url -->:jdbc:mysql://192.168.166.67:3306/dataBase2?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true
2018-01-22 16:48:37.706 [main] [com.netflix.config.sources.URLConfigurationSource.<init>] [WARN] - No URLs will be polled as dynamic configuration sources.
2018-01-22 16:48:37.706 [main] [com.netflix.config.sources.URLConfigurationSource.<init>] [INFO] - To enable URLs as dynamic configuration sources, define Sy
druid 页面
* 用户名 |
dataBase1 |
指定建立连接时使用的用户名 |
* 连接地址 |
jdbc:mysql://jdbc:mysql://192.168.166.66:3306/dataBase1 |
jdbc连接字符串 |
* 数据库类型 |
mysql |
数据库类型 |
* 驱动类名 |
com.mysql.jdbc.Driver |
jdbc驱动的类名 |
* filter类名 |
com.alibaba.druid.filter.stat.StatFilter,com.alibaba.druid.wall.WallFilter,com.alibaba.druid.filter.logging.Log4jFilter |
* 用户名 |
dataBase2 |
指定建立连接时使用的用户名 |
* 连接地址 |
jdbc:mysql://192.168.166.67:3306/dataBase2?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true |
jdbc连接字符串 |
* 数据库类型 |
mysql |
数据库类型 |
* 驱动类名 |
com.mysql.jdbc.Driver |
jdbc驱动的类名 |
* filter类名 |
com.alibaba.druid.filter.stat.StatFilter,com.alibaba.druid.wall.WallFilter,com.alibaba.druid.filter.logging.Log4jFilter |
spring boot +mybatis+druid 多数据源配置的更多相关文章
- spring boot + mybatis + druid配置实践
最近开始搭建spring boot工程,将自身实践分享出来,本文将讲述spring boot + mybatis + druid的配置方案. pom.xml需要引入mybatis 启动依赖: < ...
- Spring Boot 2.x 多数据源配置之 MyBatis 篇
场景假设:现有电商业务,商品和库存分别放在不同的库 配置数据库连接 app: datasource: first: driver-class-name: com.mysql.cj.jdbc.Drive ...
- Spring Boot + MyBatis + Druid + Redis + Thymeleaf 整合小结
Spring Boot + MyBatis + Druid + Redis + Thymeleaf 整合小结 这两天闲着没事想利用**Spring Boot**加上阿里的开源数据连接池**Druid* ...
- 13、Spring Boot 2.x 多数据源配置
1.13 Spring Boot 2.x 多数据源配置 完整源码: Spring-Boot-Demos
- Spring Boot + Mybatis + Druid 动态切换多数据源
在大型应用程序中,配置主从数据库并使用读写分离是常见的设计模式. 在Spring应用程序中,要实现读写分离,最好不要对现有代码进行改动,而是在底层透明地支持. 这样,就需要我们再一个项目中,配置两个, ...
- spring boot + mybatis + druid
因为在用到spring boot + mybatis的项目时候,经常发生访问接口卡,服务器项目用了几天就很卡的甚至不能访问的情况,而我们的项目和数据库都是好了,考虑到可能时数据库连接的问题,所以我打算 ...
- (15)Spring Boot使用Druid和监控配置【从零开始学Spring Boot】
Spring Boot 系列博客] 更多查看博客:http://412887952-qq-com.iteye.com/blog Spring Boot默认的数据源是:org.apache.tomcat ...
- Spring Boot + Mybatis 实现动态数据源
动态数据源 在很多具体应用场景的时候,我们需要用到动态数据源的情况,比如多租户的场景,系统登录时需要根据用户信息切换到用户对应的数据库.又比如业务A要访问A数据库,业务B要访问B数据库等,都可以使用动 ...
- Mybatis+Druid多数据源配置
在日常开发中我们可能会用到多数据源开发,什么是多数据源? 简单来讲的话,就是一个项目连接多个数据库.当然只是可能会用到,我暂时没见过应用场景,但是还是了解学习一下 此项目可以基于上一个简单集成项目进行 ...
随机推荐
- 基于CentOS与VmwareStation10搭建hadoop环境
基于CentOS与VmwareStation10搭建hadoop环境 目 录 1. 概述.... 1 1.1. 软件准备.... 1 1.2. 硬件准备.... 1 2. 安装与配置虚拟机.. ...
- VMware Workstation 重启服务脚本 解决连不上ssh问题
解决虚拟机,每次启动连不上ssh问题,需要关闭虚拟机,再执行脚本.执行完后,再启动虚拟机就可以连上ssh啦! 脚本名称:vmware_server_restart.bat (请以管理员身份运行,否则可 ...
- 解决html视频播放只有声音没有图像的办法
HTML5中并没有指定视频解码器,它留给了浏览器来决定. MP4有四种编码格式(MPEG4(DivX),MPEG4(Xvid),AVC(H264),HEVC(H265)): 只有使用AVC(H264) ...
- apache2.4 的安装
Apache2.4 安装包下载地址 http://httpd.apache.org/docs/current/platform/windows.html#down 选择ApacheHaus 进入后 这 ...
- 十个书写Node.js REST API的最佳实践(下)
收录待用,修改转载已取得腾讯云授权 5. 对你的Node.js REST API进行黑盒测试 测试你的REST API最好的方法之一就是把它们当成黑盒对待. 黑盒测试是一种测试方法,通过这种方法无需知 ...
- 突破防盗链机制:使用referrer-killer
在开发it博客汇的过程中遇到一个难题:很多图片链接设置了防盗链机制,从我的网站请求图片会返回403错误,但直接在浏览器中打开图片的url时却又正常. 使用fiddler抓包发现,从我的网站请求图片会带 ...
- 倍福TwinCAT(贝福Beckhoff)常见问题(FAQ)-如何添加Scope监控
添加一个Scope YT NC项目 默认添加的就是对Axis_1的监控,位置,速度和加速度都有,可以删除模长的监控(Position modulo) 点击Record就可以记录曲线了(要停止记 ...
- JRE与JVM、JDK的区别
JRE与JVM.JDK的区别 一. 详细介绍1.JVM -- java virtual machine JVM就是我们常说的java虚拟机,它是整个java实现跨平台的 最核心的部分,所有的java程 ...
- TJU Easier Done than Said?
Password security is a tricky thing. Users prefer simple passwords that are easy to remember (like ...
- hdu 4506 小明系列故事——师兄帮帮忙【幂取模乱搞】
链接: http://acm.hdu.edu.cn/showproblem.php?pid=4506 http://acm.hust.edu.cn/vjudge/contest/view.action ...