apollo源码同时兼容mysql、postgresql、oracle解决思路
apollo源码采用的是jpa规范 Hibernate 进行持久化的ORM框架
解决思路:
思路一:使用jpa配置文件persistence.xml文件,根据使用的数据库动态加载实体类与数据库中实体类的映射关系,因此可以完全是用xml实现
思路二:由于xml配置的优先级高于注解配置,如果项目中既用到注解又用到xml,配置xml会覆盖注解的映射关系
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="persistenceUnit-mysql" transaction-type="RESOURCE_LOCAL" >
<mapping-file>META-INF/orm-mysql.xml</mapping-file>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
</properties>
</persistence-unit>
<persistence-unit name="persistenceUnit-pg" transaction-type="RESOURCE_LOCAL" >
<mapping-file>META-INF/orm-pg.xml</mapping-file>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL9Dialect" />
</properties>
</persistence-unit>
<persistence-unit name="persistenceUnit-oracle" transaction-type="RESOURCE_LOCAL" >
<mapping-file>META-INF/orm-oracle.xml</mapping-file>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
</properties>
</persistence-unit>
</persistence>
orm-mysql.xml
<entity-mappings version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
http://xmlns.jcp.org/xml/ns/persistence/orm_2_1.xsd">
<entity class="com.ctrip.framework.apollo.common.entity.AppNamespace" name="AppNamespace"/>
<entity class="com.ctrip.framework.apollo.common.entity.App" name="App"/>
<entity class="com.ctrip.framework.apollo.biz.entity.Audit" name="Audit"/>
<entity class="com.ctrip.framework.apollo.biz.entity.Cluster" name="Cluster"/>
<entity class="com.ctrip.framework.apollo.biz.entity.Commit" name="Commit">
<attributes>
<!-- mysql longtext类型使用lob标注-->
<basic name="changeSets">
<lob/>
</basic>
</attributes>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.GrayReleaseRule" name="GrayReleaseRule"/>
<entity class="com.ctrip.framework.apollo.biz.entity.Instance" name="Instance"/>
<entity class="com.ctrip.framework.apollo.biz.entity.InstanceConfig" name="InstanceConfig"/>
<entity class="com.ctrip.framework.apollo.biz.entity.Item" name="Item">
<attributes>
<!-- mysql longtext使用lob标注-->
<basic name="value">
<lob/>
</basic>
</attributes>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.Namespace" name="Namespace"/>
<entity class="com.ctrip.framework.apollo.biz.entity.NamespaceLock" name="NamespaceLock"/>
<entity class="com.ctrip.framework.apollo.biz.entity.Privilege" name="Privilege"/>
<entity class="com.ctrip.framework.apollo.biz.entity.ReleaseHistory" name="ReleaseHistory"/>
<entity class="com.ctrip.framework.apollo.biz.entity.Release" name="Release">
<attributes>
<!-- mysql longtext使用lob标注-->
<basic name="configurations">
<lob/>
</basic>
</attributes>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.ReleaseMessage" name="ReleaseMessage"/>
<entity class="com.ctrip.framework.apollo.biz.entity.ServerConfig" name="ServerConfig"/>
</entity-mappings>
orm-oracle.xml映射配置
<entity-mappings version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
http://xmlns.jcp.org/xml/ns/persistence/orm_2_1.xsd">
<mapped-superclass class="com.ctrip.framework.apollo.common.entity.BaseEntity">
<attributes>
<id name="id">
<generated-value strategy="SEQUENCE" generator="sequence" />
</id>
</attributes>
</mapped-superclass>
<entity class="com.ctrip.framework.apollo.common.entity.AppNamespace" name="AppNamespace">
<sequence-generator name="sequence" allocation-size="1" sequence-name="appnamespace_id_seq"/>
<attributes>
<basic name="comment">
<column name ='"COMMENT"'></column>
</basic>
</attributes>
</entity>
<entity class="com.ctrip.framework.apollo.common.entity.App" name="App">
<sequence-generator name="sequence" allocation-size="1" sequence-name="app_id_seq"/>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.Audit" name="Audit">
<table name='"AUDIT"'/>
<sequence-generator name="sequence" allocation-size="1" sequence-name="audit_id_seq"/>
<attributes>
<basic name="comment">
<column name ='"COMMENT"'></column>
</basic>
</attributes>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.Cluster" name="Cluster">
<table name='"CLUSTER"'/>
<sequence-generator name="sequence" allocation-size="1" sequence-name="cluster_id_seq"/>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.Commit" name="Commit">
<table name='"COMMIT"'/>
<sequence-generator name="sequence" allocation-size="1" sequence-name="commit_id_seq"/>
<attributes>
<basic name="comment">
<column name ='"COMMENT"'></column>
</basic>
</attributes>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.GrayReleaseRule" name="GrayReleaseRule">
<sequence-generator name="sequence" allocation-size="1" sequence-name="grayreleaserule_id_seq"/>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.Instance" name="Instance">
<attributes>
<id name="id">
<generated-value strategy="SEQUENCE" generator="instance_id_seq"/>
<sequence-generator name="instance_id_seq" sequence-name="instance_id_seq" allocation-size="1"/>
</id>
</attributes>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.InstanceConfig" name="InstanceConfig">
<attributes>
<id name="id">
<generated-value strategy="SEQUENCE" generator="instanceconfig_id_seq"/>
<sequence-generator name="instanceconfig_id_seq" sequence-name="instanceconfig_id_seq" allocation-size="1"/>
</id>
</attributes>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.Item" name="Item">
<sequence-generator name="sequence" allocation-size="1" sequence-name="item_id_seq"/>
<attributes>
<basic name="comment" >
<column name='"COMMENT"'/>
</basic>
</attributes>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.Namespace" name="Namespace">
<sequence-generator name="sequence" allocation-size="1" sequence-name="namespace_id_seq"/>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.NamespaceLock" name="NamespaceLock">
<sequence-generator name="sequence" allocation-size="1" sequence-name="namespacelock_id_seq"/>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.Privilege" name="Privilege">
<sequence-generator name="sequence" allocation-size="1" sequence-name="privilege_id_seq"/>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.Release" name="Release">
<sequence-generator name="sequence" allocation-size="1" sequence-name="release_id_seq"/>
<attributes>
<basic name="comment" >
<column name='"COMMENT"'/>
</basic>
</attributes>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.ReleaseHistory" name="ReleaseHistory">
<sequence-generator name="sequence" allocation-size="1" sequence-name="releasehistory_id_seq"/>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.ReleaseMessage" name="ReleaseMessage">
<attributes>
<id name="id">
<generated-value strategy="SEQUENCE" generator="releasemessage_id_seq"/>
<sequence-generator name="releasemessage_id_seq" sequence-name="releasemessage_id_seq" allocation-size="1"/>
</id>
</attributes>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.ServerConfig" name="ServerConfig">
<sequence-generator name="sequence" allocation-size="1" sequence-name="serverconfig_id_seq"/>
<attributes>
<basic name="cluster" >
<column name='"CLUSTER"'/>
</basic>
<basic name="comment" >
<column name='"COMMENT"'/>
</basic>
</attributes>
</entity>
</entity-mappings>
orm-pg.xml映射配置
<entity-mappings version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
http://xmlns.jcp.org/xml/ns/persistence/orm_2_1.xsd">
<mapped-superclass class="com.ctrip.framework.apollo.common.entity.BaseEntity">
<attributes>
<id name="id">
<generated-value strategy="SEQUENCE" generator="sequence" />
</id>
</attributes>
</mapped-superclass>
<entity class="com.ctrip.framework.apollo.common.entity.AppNamespace" name="AppNamespace">
<sequence-generator name="sequence" allocation-size="1" sequence-name="appnamespace_id_seq"/>
</entity>
<entity class="com.ctrip.framework.apollo.common.entity.App" name="App">
<sequence-generator name="sequence" allocation-size="1" sequence-name="app_id_seq"/>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.Audit" name="Audit">
<sequence-generator name="sequence" allocation-size="1" sequence-name="audit_id_seq"/>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.Cluster" name="Cluster">
<sequence-generator name="sequence" allocation-size="1" sequence-name="cluster_id_seq"/>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.Commit" name="Commit">
<sequence-generator name="sequence" allocation-size="1" sequence-name="commit_id_seq"/>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.GrayReleaseRule" name="GrayReleaseRule">
<sequence-generator name="sequence" allocation-size="1" sequence-name="grayreleaserule_id_seq"/>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.Instance" name="Instance">
<attributes>
<id name="id">
<generated-value strategy="SEQUENCE" generator="instance_id_seq"/>
<sequence-generator name="instance_id_seq" sequence-name="instance_id_seq" allocation-size="1"/>
</id>
</attributes>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.InstanceConfig" name="InstanceConfig">
<attributes>
<id name="id">
<generated-value strategy="SEQUENCE" generator="instanceconfig_id_seq"/>
<sequence-generator name="instanceconfig_id_seq" sequence-name="instanceconfig_id_seq" allocation-size="1"/>
</id>
</attributes>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.Item" name="Item">
<sequence-generator name="sequence" allocation-size="1" sequence-name="item_id_seq"/>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.Namespace" name="Namespace">
<sequence-generator name="sequence" allocation-size="1" sequence-name="namespace_id_seq"/>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.NamespaceLock" name="NamespaceLock">
<sequence-generator name="sequence" allocation-size="1" sequence-name="namespacelock_id_seq"/>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.Privilege" name="Privilege">
<sequence-generator name="sequence" allocation-size="1" sequence-name="privilege_id_seq"/>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.Release" name="Release">
<sequence-generator name="sequence" allocation-size="1" sequence-name="release_id_seq"/>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.ReleaseHistory" name="ReleaseHistory">
<sequence-generator name="sequence" allocation-size="1" sequence-name="releasehistory_id_seq"/>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.ReleaseMessage" name="ReleaseMessage">
<attributes>
<id name="id">
<generated-value strategy="SEQUENCE" generator="releasemessage_id_seq"/>
<sequence-generator name="releasemessage_id_seq" sequence-name="releasemessage_id_seq" allocation-size="1"/>
</id>
</attributes>
</entity>
<entity class="com.ctrip.framework.apollo.biz.entity.ServerConfig" name="ServerConfig">
<sequence-generator name="sequence" allocation-size="1" sequence-name="serverconfig_id_seq"/>
</entity>
</entity-mappings>
动态加载配置类
package com.ctrip.framework.apollo.adminservice.configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import javax.annotation.Resource;
import javax.sql.DataSource;
import java.util.Map;
@Configuration
@EnableJpaRepositories(
entityManagerFactoryRef = "entityManagerFactory",
transactionManagerRef = "transactionManager",
basePackages = {"com.ctrip.framework.apollo.biz.repository"})
public class JpaConfig {
@Resource
private JpaProperties jpaProperties;
@Resource
private DataSourceProperties dataSourceProperties;
@Bean
public JpaVendorAdapter jpaVendorAdapter() {
HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
hibernateJpaVendorAdapter.setShowSql(jpaProperties.isShowSql());
hibernateJpaVendorAdapter.setGenerateDdl(jpaProperties.isGenerateDdl());
hibernateJpaVendorAdapter.setDatabase(jpaProperties.getDatabase());
return hibernateJpaVendorAdapter;
}
/**
* 数据源
*/
@Bean(name = "dataSource")
public DataSource dataSource() {
//apollo默认使用的是org.apache.tomcat.jdbc.pool.DataSource
org.apache.tomcat.jdbc.pool.DataSource dataSource = new org.apache.tomcat.jdbc.pool.DataSource();
dataSource.setUrl(dataSourceProperties.getUrl());
dataSource.setUsername(dataSourceProperties.getUsername());
dataSource.setPassword(dataSourceProperties.getPassword());
dataSource.setDriverClassName(dataSourceProperties.getDriverClassName());
dataSource.setValidationQuery(dataSourceProperties.getValidationQuery());
dataSource.setValidationInterval(dataSourceProperties.getValidationInterval());
dataSource.setTestWhileIdle(dataSourceProperties.isTestWhileIdle());
dataSource.setTestOnBorrow(dataSourceProperties.isTestOnBorrow());
if (dataSourceProperties.getUrl().contains("jdbc:mysql")) {
dataSource.setInitSQL(dataSourceProperties.getInitSql());
}
return dataSource;
}
/**
* 创建 LocalContainerEntityManagerFactoryBean
*/
@Bean(name = "entityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
LocalContainerEntityManagerFactoryBean entityManager = new LocalContainerEntityManagerFactoryBean();
entityManager.setDataSource(this.dataSource());
entityManager.setJpaVendorAdapter(jpaVendorAdapter());
entityManager.setPackagesToScan("com.ctrip.framework.apollo.biz.entity","com.ctrip.framework.apollo.common.entity");
Map<String, String> jpaProperties = this.jpaProperties.getProperties();
entityManager.setJpaPropertyMap(jpaProperties);
//PersistenceUnit默认使用mysql的persistenceUnit-mysql, pg方式时切换到persistenceUnit-pg
//PersistenceUnit在persistence.xml中定义
entityManager.setPersistenceUnitName("persistenceUnit-mysql");
if (dataSourceProperties.getUrl().contains("jdbc:postgresql")) {
entityManager.setPersistenceUnitName("persistenceUnit-pg");
}
if(dataSourceProperties.getUrl().contains("jdbc:oracle")){
entityManager.setPersistenceUnitName("persistenceUnit-oracle");
}
return entityManager;
}
}
-----set 、get省略
@Component
@ConfigurationProperties("spring.datasource")
public class DataSourceProperties {
private String driverClassName;
private String url = "";
private String username;
private String password;
private int maxPoolSize;
private int minPoolSize;
private String uniqueResourceName;
private String validationQuery;
private int validationInterval;
private String initSql;
private boolean testWhileIdle;
private boolean testOnBorrow;
}
package com.ctrip.framework.apollo.adminservice.configuration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDatabaseConnection;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.orm.jpa.vendor.Database;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import javax.sql.DataSource;
import java.util.HashMap;
import java.util.Map;
/**
* External configuration properties for a JPA EntityManagerFactory created by Spring.
*/
@Component
@ConfigurationProperties(prefix = "spring.jpa")
public class JpaProperties {
private static final Log logger = LogFactory.getLog(JpaProperties.class);
/**
* Additional native properties to set on the JPA provider.
*/
private Map<String, String> properties = new HashMap<String, String>();
/**
* Name of the target database to operate on, auto-detected by default. Can be
* alternatively set using the "Database" enum.<br>
* for example:org.hibernate.dialect.MySQLDialect
*/
private String databasePlatform;
/**
* Target database to operate on, auto-detected by default. Can be alternatively set
* using the "databasePlatform" property.
*/
private Database database = Database.DEFAULT;
/**
* Initialize the schema on startup.
*/
private boolean generateDdl = false;
/**
* Enable logging of SQL statements.
*/
private boolean showSql = false;
private Hibernate hibernate = new Hibernate();
public Map<String, String> getProperties() {
return this.properties;
}
public void setProperties(Map<String, String> properties) {
this.properties = properties;
}
public String getDatabasePlatform() {
return this.databasePlatform;
}
public void setDatabasePlatform(String databasePlatform) {
this.databasePlatform = databasePlatform;
}
public Database getDatabase() {
return this.database;
}
public void setDatabase(Database database) {
this.database = database;
}
public boolean isGenerateDdl() {
return this.generateDdl;
}
public void setGenerateDdl(boolean generateDdl) {
this.generateDdl = generateDdl;
}
public boolean isShowSql() {
return this.showSql;
}
public void setShowSql(boolean showSql) {
this.showSql = showSql;
}
public Hibernate getHibernate() {
return this.hibernate;
}
public void setHibernate(Hibernate hibernate) {
this.hibernate = hibernate;
}
/**
* Get configuration properties for the initialization of the main Hibernate
* EntityManagerFactory.
* @param dataSource the DataSource in case it is needed to determine the properties
* @return some Hibernate properties for configuration
*/
public Map<String, String> getHibernateProperties(DataSource dataSource) {
return this.hibernate.getAdditionalProperties(this.properties, dataSource);
}
public static class Hibernate {
private static final String DEFAULT_NAMING_STRATEGY = "org.springframework.boot.orm.jpa.hibernate.SpringNamingStrategy";
/**
* Naming strategy fully qualified name.
*/
private Class<?> namingStrategy;
/**
* DDL mode ("none", "validate", "update", "create", "create-drop"). This is
* actually a shortcut for the "hibernate.hbm2ddl.auto" property. Default to
* "create-drop" when using an embedded database, "none" otherwise.
*/
private String ddlAuto;
private boolean globallyQuotedIdentifiers;
public boolean isGloballyQuotedIdentifiers() {
return globallyQuotedIdentifiers;
}
public void setGloballyQuotedIdentifiers(boolean globallyQuotedIdentifiers) {
this.globallyQuotedIdentifiers = globallyQuotedIdentifiers;
}
public Class<?> getNamingStrategy() {
return this.namingStrategy;
}
public void setNamingStrategy(Class<?> namingStrategy) {
this.namingStrategy = namingStrategy;
}
@Deprecated
public void setNamingstrategy(Class<?> namingStrategy) {
logger.warn("The property spring.jpa.namingstrategy has been renamed, "
+ "please update your configuration to use namingStrategy or naming-strategy or naming_strategy");
this.setNamingStrategy(namingStrategy);
}
public String getDdlAuto() {
return this.ddlAuto;
}
public void setDdlAuto(String ddlAuto) {
this.ddlAuto = ddlAuto;
}
private Map<String, String> getAdditionalProperties(Map<String, String> existing,
DataSource dataSource) {
Map<String, String> result = new HashMap<String, String>(existing);
if (!isAlreadyProvided(existing, "ejb.naming_strategy")
&& this.namingStrategy != null) {
result.put("hibernate.ejb.naming_strategy", this.namingStrategy.getName());
}
else if (this.namingStrategy == null) {
result.put("hibernate.ejb.naming_strategy", DEFAULT_NAMING_STRATEGY);
}
String ddlAuto = getOrDeduceDdlAuto(existing, dataSource);
if (StringUtils.hasText(ddlAuto) && !"none".equals(ddlAuto)) {
result.put("hibernate.hbm2ddl.auto", ddlAuto);
}
else {
result.remove("hibernate.hbm2ddl.auto");
}
return result;
}
private String getOrDeduceDdlAuto(Map<String, String> existing,
DataSource dataSource) {
String ddlAuto = (this.ddlAuto != null ? this.ddlAuto
: getDefaultDdlAuto(dataSource));
if (!isAlreadyProvided(existing, "hbm2ddl.auto") && !"none".equals(ddlAuto)) {
return ddlAuto;
}
if (isAlreadyProvided(existing, "hbm2ddl.auto")) {
return existing.get("hibernate.hbm2ddl.auto");
}
return "none";
}
private String getDefaultDdlAuto(DataSource dataSource) {
if (EmbeddedDatabaseConnection.isEmbedded(dataSource)) {
return "create-drop";
}
return "none";
}
private boolean isAlreadyProvided(Map<String, String> existing, String key) {
return existing.containsKey("hibernate." + key);
}
}
}
数据库坐标依赖
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.4</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.4.0</version>
</dependency>
本地实现的环境:
<java.version>1.8</java.version>
<tomcat.version>8.5.23</tomcat.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring-boot.version>1.3.8.RELEASE</spring-boot.version>
<spring-cloud.version>1.2.3.RELEASE</spring-cloud.version>
<!-- Plugins Version -->
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
apollo源码同时兼容mysql、postgresql、oracle解决思路的更多相关文章
- 2-14 MySQL初步认识,及CentOS6.8环境,源码方式安装MySQL
什么是数据库: 存放数据的仓库RDBMS-->(Relational Database Management System) 关系型数据库管理系统DBMS--->(Database Man ...
- 3.9 run_main.py源码(兼容python2和3)
3.9 run_main.py源码(兼容python2和3) 以下代码在python2和python3上都跑通过,python3只需注释掉上面红色框框区域代码就行(最后一步发送邮箱代码,我注释掉了). ...
- Apollo源码阅读笔记(二)
Apollo源码阅读笔记(二) 前面 分析了apollo配置设置到Spring的environment的过程,此文继续PropertySourcesProcessor.postProcessBeanF ...
- Apollo源码阅读笔记(一)
Apollo源码阅读笔记(一) 先来一张官方客户端设计图,方便我们了解客户端的整体思路. 我们在使用Apollo的时候,需要标记@EnableApolloConfig来告诉程序开启apollo配置,所 ...
- 实操重写IK分词器源码,基于mysql热更新词库
实操重写IK分词器源码,基于mysql热更新词库参考网址:https://blog.csdn.net/wuzhiwei549/article/details/80451302 问题一:按照这篇文章的介 ...
- Apollo源码解析看一文就够
对于配置中心我们先抛出问号三连,什么是配置中心?为什么要用配置中心?配置中心怎么用? 笔者说说自己理解的配置中心,个人观点的十六字 消息存储 消息推送 环境隔离 灰度发布 今天我们先来看Apollo配 ...
- 32.修改IK分词器源码来基于mysql热更新词库
主要知识点, 修改IK分词器源码来基于mysql热更新词库 一.IK增加新词的原因 在第32小节中学习到了直接在es的词库中增加词语,来扩充自已的词库,但是这样做有以下缺点: (1)每次添加完 ...
- Apollo源码打包及部署
1. 通过源码打包 到携程Apollo地址 https://github.com/ctripcorp/apollo 下载Apollo源码,可在源码中进行自定义配置日志路径及端口等,之后打包. 打包完成 ...
- CentOS源码编译安装MySQL 5.5.15
CentOS源码编译安装MySQL 5.5.15 文章目录 [隐藏] 安装编译工具 下载源码 安装cmake和bison 编译安装MySQL 一些相关设置 安装编译工具 yum install g ...
- CentOS 6.6 下源码编译安装MySQL 5.7.5
版权声明:转自:http://www.linuxidc.com/Linux/2015-08/121667.htm 说明:CentOS 6.6 下源码编译安装MySQL 5.7.5 1. 安装相关工具# ...
随机推荐
- mysql 错误解决大法 Specified key was too long; max key length is 767 bytes
高版本mysql向低版本(5.7以下)导入sql时可能会发生此问题 开启索引最大长度 SET GLOBAL INNODB_LARGE_PREFIX = ON; 将表改为动态表SET GLOBAL in ...
- python学习day 02
昨日内容回顾 typora软件 1.作为一款逐年火爆的文本编辑器,深受IT行业的喜爱. 2.下载与安装: windows用群里发的软件 macOS下载地址:https://mac.qdrayst.co ...
- 最长上升子序列 II 时间复杂度(nlogn)
题目:最长上升子序列 II 给定一个长度为 N 的数列,求数值严格单调递增的子序列的长度最长是多少. 输入格式 第一行包含整数 N. 第二行包含 N个整数,表示完整序列. 输出格式 输出一个整数,表示 ...
- Bootstrap的Modal与WebUploader联用的问题及办法
问题描述:在使用Bootstrap的Modal的时候,在Modal中用了WebUploader插件,然后WebUploader的绑定按钮无法点击 在网上找了一些结果,觉得,他们的问题解决方案感觉都不够 ...
- Vue急速入门-5
vue-cli创建项目 前端工程化,项目>>>(vue-cli),创建处vue项目,单页面应用(spa) vue-cli创建项目开发,在项目中开发,最后上线,一定要编译 '纯粹的ht ...
- MySQL视图、存储过程、函数、触发器、定时任务、流程控制总结
视图的增删改查 视图相当于一张只能读的表,不可以修改.当组成视图的表发生数据变化的时候,视图会相对应的进行改变. 存储过程的练习 创建存储过程: create [if not exists] proc ...
- 自己从零写操作系统GrapeOS系列教程——4.GrapeOS开发环境介绍
1. 开发环境简介 为了减少开发过程中不必要的麻烦,希望大家的开发环境尽量与我的保持一致. 我的开发环境如下: Windows10电脑一台 Visual Studio Code(最好是最新版) Vir ...
- DrCush_0813_风湿性疾病, 药物和新冠指南
风湿性疾病, 药物和新冠指南 原文网址: https://rheumnow.com/news/rheumatic-diseases-drugs-and-covid-19-guidelines Jack ...
- postgresql VACUUM 不会从表中删除死行的三个原因
一.为什么是VACUUM? 每当更新或删除PostgreSQL表中的行时,都会留下死元组.VACUUM摆脱了它们,以便空间可以重复使用.如果一个表没有被清理,它就会变得臃肿,这会浪费磁盘空间并减慢表的 ...
- postgresql中条件表达式 coalesce、nullif 、greatest、least
一.postgresql中条件表达式 1.1 GREATEST和LEASTGREATEST(value [, ...]) LEAST(value [, ...])# 注意比较值得类型一定要相同案例:比 ...