一 Hibernate继承映射

  我们可以将继承层次结构类与数据库的表映射。

1. 每个层次类一张表

这个层次结构有三个类,EmployeeRegular_EmployeeContract_Employee类的超类(父类)。

此层次结构的表结构如下所示:

XML实现

1)创建持久化类

Employee.java

package cn;

public class Employee {

	private int id;

	private String name;

	public int getId() {
return id;
} public void setId(int id) {
this.id = id;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} }

 Regular_Employee.java

package cn;

public class Regular_Employee extends Employee{

private float salary;

private int bonus;

public float getSalary() {
return salary;
}

public void setSalary(float salary) {
this.salary = salary;
}

public int getBonus() {
return bonus;
}

public void setBonus(int bonus) {
this.bonus = bonus;
}

}

  Contract_Employee.java

package cn;

public class Contract_Employee extends Employee{

private float pay_per_hour;
private String contract_duration;
public float getPay_per_hour() {
return pay_per_hour;
}
public void setPay_per_hour(float pay_per_hour) {
this.pay_per_hour = pay_per_hour;
}
public String getContract_duration() {
return contract_duration;
}
public void setContract_duration(String contract_duration) {
this.contract_duration = contract_duration;
}

}

  2)创建映射文件

在每个类层次结构一个表的情况下,hibernate框架添加了一个标识符列,该框架指定了记录的类型。 它主要用于区分记录。要指定它,必须指定类的 discriminator 子元素。
类的子类subelement指定子类。 在这种情况下,Regular_EmployeeContract_EmployeeEmployee类的子类。

Employee.hbm.xml

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping>
<class name="cn.Employee" table="employee">
<id name="id">
<generator class="increment"></generator>
</id>
<discriminator column="type" type="string"></discriminator>
<property name="name"></property> <subclass name = "cn.Regular_Employee" discriminator-value="reg_emp">
<property name="salary"></property>
<property name="bonus"></property>
</subclass> <subclass name = "cn.Contract_Employee" discriminator-value="con_emp">
<property name="pay_per_hour"></property>
<property name="contract_duration"></property>
</subclass> </class> </hibernate-mapping>

  3)在配置文件中增加Employee.hbm.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hbm2ddl.auto">update</property>
<property name="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="hibernate.connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="hibernate.connection.url">
jdbc:mysql://localhost/test
</property>
<property name="hibernate.connection.username">
root
</property>
<property name="hibernate.connection.password">
root
</property>
<property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
<property name="show_sql">true</property>
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="cache.provider_class">org.hibernate.cache.EhCacheProvider</property>

<!-- List of XML mapping files -->
<mapping resource="cn/Employee.hbm.xml"/>
</session-factory>
</hibernate-configuration>

  4)测试

package cn;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration; import com.User; public class Test { public static void main(String[] args) {
Configuration cfg = new Configuration();
cfg.configure("hibernate.cfg.xml");
SessionFactory factory = cfg.buildSessionFactory();
Session session = factory.openSession();
session.beginTransaction(); Employee emp = new Employee();
emp.setName("emp"); Regular_Employee reg = new Regular_Employee();
reg.setName("reg_emp");
reg.setSalary(10000);
reg.setBonus(1); Contract_Employee con = new Contract_Employee();
con.setName("con_emp");
con.setPay_per_hour(200);
con.setContract_duration("20h"); session.persist(emp);
session.persist(reg);
session.persist(con); session.getTransaction().commit();
session.close();
}
}

  

注解实现

1)创建持久化类

Employee.java

package cn;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table; @Entity
@Table(name="employee")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="type",discriminatorType=DiscriminatorType.STRING)
@DiscriminatorValue(value="employeee")
public class Employee { @Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="id")
private int id; @Column(name="name")
private String name; public int getId() {
return id;
} public void setId(int id) {
this.id = id;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} }

  Regular_Employee.java

package cn;

import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity; @Entity
@DiscriminatorValue(value="reg")
public class Regular_Employee extends Employee{ @Column(name="salary")
private float salary; @Column(name="bonus")
private int bonus; public float getSalary() {
return salary;
} public void setSalary(float salary) {
this.salary = salary;
} public int getBonus() {
return bonus;
} public void setBonus(int bonus) {
this.bonus = bonus;
} }

  Contract_Employee.java

package cn;

import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity; @Entity
@DiscriminatorValue(value="con")
public class Contract_Employee extends Employee{ @Column(name="pay_per_hour")
private float pay_per_hour;
@Column(name="contract_duration")
private String contract_duration;
public float getPay_per_hour() {
return pay_per_hour;
}
public void setPay_per_hour(float pay_per_hour) {
this.pay_per_hour = pay_per_hour;
}
public String getContract_duration() {
return contract_duration;
}
public void setContract_duration(String contract_duration) {
this.contract_duration = contract_duration;
} }

  2)配置文件中增加持久化类

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hbm2ddl.auto">update</property>
<property name="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="hibernate.connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="hibernate.connection.url">
jdbc:mysql://localhost/test
</property>
<property name="hibernate.connection.username">
root
</property>
<property name="hibernate.connection.password">
root
</property>
<property name="show_sql">true</property>
<mapping class="cn.Employee"/>
<mapping class="cn.Regular_Employee"/>
<mapping class="cn.Contract_Employee"/>
</session-factory>
</hibernate-configuration>

  3)测试

package cn;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.AnnotationConfiguration; public class Test { public static void main(String[] args) { SessionFactory factory = new AnnotationConfiguration().configure().buildSessionFactory();
Session session = factory.openSession();
Transaction t = session.beginTransaction(); t.begin(); Employee emp = new Employee();
emp.setName("emp"); Regular_Employee reg = new Regular_Employee();
reg.setName("reg_emp");
reg.setSalary(10000);
reg.setBonus(1); Contract_Employee con = new Contract_Employee();
con.setName("con_emp");
con.setPay_per_hour(200);
con.setContract_duration("20h"); session.persist(emp);
session.persist(reg);
session.persist(con); t.commit(); session.close(); } }

  

2. 每个具体类一张表

数据库中将有三个表,彼此之间没有关系。

XML实现

1) 创建持久化类

Employee.java

package cnn;

public class Employee {

	private int id;

	private String name;

	public int getId() {
return id;
} public void setId(int id) {
this.id = id;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} }

Regular_Employee.java

package cnn;

public class Regular_Employee extends Employee{

	private float salary;

	private int bonus;

	public float getSalary() {
return salary;
} public void setSalary(float salary) {
this.salary = salary;
} public int getBonus() {
return bonus;
} public void setBonus(int bonus) {
this.bonus = bonus;
} }

Contract_Employee.java

package cnn;

public class Contract_Employee extends Employee {
private float pay_per_hour;
private String contract_duration;
public float getPay_per_hour() {
return pay_per_hour;
}
public void setPay_per_hour(float pay_per_hour) {
this.pay_per_hour = pay_per_hour;
}
public String getContract_duration() {
return contract_duration;
}
public void setContract_duration(String contract_duration) {
this.contract_duration = contract_duration;
} }

  

2)employee.hbm.xml

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping>
<class name="cnn.Employee" table="employee">
<id name="id">
<generator class="increment"></generator>
</id>
<property name="name"></property> <union-subclass name = "cnn.Regular_Employee" table="regular" >
<property name="salary"></property>
<property name="bonus"></property>
</union-subclass> <union-subclass name = "cnn.Contract_Employee" table="contract">
<property name="pay_per_hour"></property>
<property name="contract_duration"></property>
</union-subclass> </class> </hibernate-mapping>

3) 在配置文件中增加hbm文件的映射

 	<!-- List of XML mapping files -->
<mapping resource="cnn/Employee.hbm.xml"/>

4)测试

package cnn;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration; import com.User; public class Test { public static void main(String[] args) {
Configuration cfg = new Configuration();
cfg.configure("hibernate.cfg.xml");
SessionFactory factory = cfg.buildSessionFactory();
Session session = factory.openSession();
session.beginTransaction(); Employee emp = new Employee();
emp.setName("emp"); Regular_Employee reg = new Regular_Employee();
reg.setName("reg_emp");
reg.setSalary(10000);
reg.setBonus(1); Contract_Employee con = new Contract_Employee();
con.setName("con_emp");
con.setPay_per_hour(200);
con.setContract_duration("20h"); session.persist(emp);
session.persist(reg);
session.persist(con); session.getTransaction().commit();
session.close();
}
}

注解实现

1)创建持久化类

Employee.java

package cnn;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table; @Entity
@Table(name="employee")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Employee { @Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private int id; @Column(name = "name")
private String name; public int getId() {
return id;
} public void setId(int id) {
this.id = id;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} }

Regular_Employee.java

package cnn;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table; @Entity
@Table(name = "regular")
@AttributeOverrides({
@AttributeOverride(name = "id", column = @Column(name = "id")),
@AttributeOverride(name = "name", column = @Column(name = "name")) })
public class Regular_Employee extends Employee{ @Column(name = "salary")
private float salary; @Column(name = "bonus")
private int bonus; public float getSalary() {
return salary;
} public void setSalary(float salary) {
this.salary = salary;
} public int getBonus() {
return bonus;
} public void setBonus(int bonus) {
this.bonus = bonus;
} }

Contract_Employee.java

package cnn;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table; @Entity
@Table(name = "contract")
@AttributeOverrides({
@AttributeOverride(name = "id", column = @Column(name = "id")),
@AttributeOverride(name = "name", column = @Column(name = "name")) })
public class Contract_Employee extends Employee {
@Column(name = "pay_per_hour")
private float pay_per_hour;
@Column(name = "contract_duration")
private String contract_duration;
public float getPay_per_hour() {
return pay_per_hour;
}
public void setPay_per_hour(float pay_per_hour) {
this.pay_per_hour = pay_per_hour;
}
public String getContract_duration() {
return contract_duration;
}
public void setContract_duration(String contract_duration) {
this.contract_duration = contract_duration;
} }

2)在配置文件中添加hbm文件映射

	<mapping class="cnn.Employee"/>
<mapping class="cnn.Regular_Employee"/>
<mapping class="cnn.Contract_Employee"/>

3)测试类

package cnn;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.AnnotationConfiguration; public class Test { public static void main(String[] args) { SessionFactory factory = new AnnotationConfiguration().configure().buildSessionFactory();
Session session = factory.openSession();
Transaction t = session.beginTransaction(); t.begin(); Employee emp = new Employee();
emp.setName("emp"); Regular_Employee reg = new Regular_Employee();
reg.setName("reg_emp");
reg.setSalary(20000);
reg.setBonus(12); Contract_Employee con = new Contract_Employee();
con.setName("con_emp");
con.setPay_per_hour(100);
con.setContract_duration("30h"); session.persist(emp);
session.persist(reg);
session.persist(con); t.commit(); session.close(); } }

  

3. 每个子类一张表

在每个子类一张表的情况下,子类映射表与主键和外键的关系与父类映射表相关。

XML实现

1)创建持久化类

Employee.java

package cnnn;

public class Employee {

	private int id;

	private String name;

	public int getId() {
return id;
} public void setId(int id) {
this.id = id;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} }

  Regular_Employee.java

package cnnn;

public class Regular_Employee extends Employee{

	private float salary;

	private int bonus;

	public float getSalary() {
return salary;
} public void setSalary(float salary) {
this.salary = salary;
} public int getBonus() {
return bonus;
} public void setBonus(int bonus) {
this.bonus = bonus;
} }

  Contract_Employee.java

package cnnn;

public class Contract_Employee extends Employee{

	private float pay_per_hour;
private String contract_duration;
public float getPay_per_hour() {
return pay_per_hour;
}
public void setPay_per_hour(float pay_per_hour) {
this.pay_per_hour = pay_per_hour;
}
public String getContract_duration() {
return contract_duration;
}
public void setContract_duration(String contract_duration) {
this.contract_duration = contract_duration;
} }

2)Employee.hbm.xml

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping>
<class name="cnnn.Employee" table="employee">
<id name="id">
<generator class="increment"></generator>
</id>
<property name="name"></property> <joined-subclass name = "cnnn.Regular_Employee" >
<key column="reg_id"></key>
<property name="salary"></property>
<property name="bonus"></property>
</joined-subclass> <joined-subclass name = "cnnn.Contract_Employee" >
<key column="con_id"></key>
<property name="pay_per_hour"></property>
<property name="contract_duration"></property>
</joined-subclass> </class> </hibernate-mapping>

  

 

3)在配置文件中添加hbm文件的映射

<mapping resource="cnnn/Employee.hbm.xml"/>

4)测试

package cnnn;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration; import com.User; public class Test { public static void main(String[] args) {
Configuration cfg = new Configuration();
cfg.configure("hibernate.cfg.xml");
SessionFactory factory = cfg.buildSessionFactory();
Session session = factory.openSession();
session.beginTransaction(); Employee emp = new Employee();
emp.setName("emp"); Regular_Employee reg = new Regular_Employee();
reg.setName("reg_emp");
reg.setSalary(10000);
reg.setBonus(1); Contract_Employee con = new Contract_Employee();
con.setName("con_emp");
con.setPay_per_hour(200);
con.setContract_duration("20h"); session.persist(emp);
session.persist(reg);
session.persist(con); session.getTransaction().commit();
session.close();
}
}

注解实现

1)创建持久化类

Employee.java

package cnnn;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table; @Entity
@Table(name="employee")
@Inheritance(strategy = InheritanceType.JOINED)
public class Employee { @Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private int id; @Column(name = "name")
private String name; public int getId() {
return id;
} public void setId(int id) {
this.id = id;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} }

  Regular_Employee.java

package cnnn;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table; @Entity
@Table(name = "regular")
@PrimaryKeyJoinColumn(name = "ID")
public class Regular_Employee extends Employee{ @Column(name = "salary")
private float salary; @Column(name = "bonus")
private int bonus; public float getSalary() {
return salary;
} public void setSalary(float salary) {
this.salary = salary;
} public int getBonus() {
return bonus;
} public void setBonus(int bonus) {
this.bonus = bonus;
} }

  

package cnnn;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table; @Entity
@Table(name = "contract")
@PrimaryKeyJoinColumn(name = "ID")
public class Contract_Employee extends Employee {
@Column(name = "pay_per_hour")
private float pay_per_hour;
@Column(name = "contract_duration")
private String contract_duration;
public float getPay_per_hour() {
return pay_per_hour;
}
public void setPay_per_hour(float pay_per_hour) {
this.pay_per_hour = pay_per_hour;
}
public String getContract_duration() {
return contract_duration;
}
public void setContract_duration(String contract_duration) {
this.contract_duration = contract_duration;
} }

2)在配置文件中增加配置

	<mapping class="cnnn.Employee"/>
<mapping class="cnnn.Regular_Employee"/>
<mapping class="cnnn.Contract_Employee"/>

3)测试

package cnnn;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.AnnotationConfiguration; public class Test { public static void main(String[] args) { SessionFactory factory = new AnnotationConfiguration().configure().buildSessionFactory();
Session session = factory.openSession();
Transaction t = session.beginTransaction(); t.begin(); Employee emp = new Employee();
emp.setName("emp"); Regular_Employee reg = new Regular_Employee();
reg.setName("reg_emp");
reg.setSalary(20000);
reg.setBonus(12); Contract_Employee con = new Contract_Employee();
con.setName("con_emp");
con.setPay_per_hour(100);
con.setContract_duration("30h"); session.persist(emp);
session.persist(reg);
session.persist(con); t.commit(); session.close(); } }

  

Hibernate入门(五)的更多相关文章

  1. Hibernate入门(五)---------事务管理

    在Hibernate中,可以通过代码来操作管理事务,如通过“Transaction tx = session.beginTransaction()”,开启一个事务,持久化操作后,通过"tx. ...

  2. openresty 前端开发入门五之Mysql篇

    openresty 前端开发入门五之Mysql篇 这章主要演示怎么通过lua连接mysql,并根据用户输入的name从mysql获取数据,并返回给用户 操作mysql主要用到了lua-resty-my ...

  3. 三大框架之hibernate入门

    hibernate入门   1.orm      hibernate是一个经典的开源的orm[数据访问中间件]框架           ORM( Object Relation Mapping)对象关 ...

  4. Hibernate入门案例及增删改查

    一.Hibernate入门案例剖析: ①创建实体类Student 并重写toString方法 public class Student { private Integer sid; private I ...

  5. Hibernate入门案例 增删改

    一.Hibernate入门案例剖析: ①创建实体类Student 并重写toString方法 public class Student { private Integer sid; private I ...

  6. Hibernate入门6.Hibernate检索方式

    Hibernate入门6.Hibernate检索方式 20131128 代码下载 链接: http://pan.baidu.com/s/1Ccuup 密码: vqlv Hibernate的整体框架已经 ...

  7. Hibernate入门5持久化对象关系和批量处理技术

    Hibernate入门5持久化对象关系和批量处理技术 20131128 代码下载 链接: http://pan.baidu.com/s/1Ccuup 密码: vqlv 前言: 前面学习了Hiberna ...

  8. Hibernate入门4.核心技能

    Hibernate入门4.核心技能 20131128 代码下载 链接: http://pan.baidu.com/s/1Ccuup 密码: vqlv 前言: 前面学习了Hibernate3的基本知识, ...

  9. Hibernate入门3.配置映射文件深入

    Hibernate入门3.配置映射文件深入 2013.11.27 前言: 之前的两节是在Java项目中如何使用hibernate,并且通过一个简单地项目实践,期间有很多的错误,一般都是因为配置包的问题 ...

  10. 简单的Hibernate入门简介

    其实Hibernate本身是个独立的框架,它不需要任何web server或application server的支持.然而,大多数的Hibernate入门介绍都加入了很多非Hibernate的东西, ...

随机推荐

  1. 【转】QQ传输文件原理参考(来自互联网)

    QQ的文件发送是怎样的过程呢?通常,发送文件的计算机首先要通过消息服务器将其IP地址发送给接收计算机,当接收计算机同意接收的确认消息反馈到消息服务器后,消息服务器将据此设置好文件传输对话.随即,发送计 ...

  2. mui开发app之js将base64转图片文件

    之前我已经做过一个利用cropper裁剪并且制作头像的功能.如何在mui app中实现相册或相机获取图片后裁剪做头像请看另一篇博客:mui开发app之cropper裁剪后上传头像的实现 但是当时裁剪后 ...

  3. 使用react native制作的微博客户端

    简要说明: 因为微博授权权限设置,本人的微博开放者账号权限太低,如果出现 'api请求次数受限,请更换. 10023' 弹框 或者 授权界面出错,需要自行更换开放者应用的appkey,授权回调页,Ap ...

  4. map中结构体做关键字的注意事项

    序: 今天做一道题,由于递归函数比较恶心,如果用记忆化搜索,数据范围极大却又用不全(二维数组存的话直接炸).所以决定干脆使用stl::map存储(反正有O2优化),但是执行insert的时候,编译器却 ...

  5. 罪恶的SEO优化

    1. 基础概念开始 SEO,搜索引擎优化.概括来说就是针对分析搜索引擎的网站收录以及评价规律,来对网站的结构,内容以及其他因素作出一些合理调整,使得网站更容易被搜索引擎收录,并且能够尽量排在搜索引擎自 ...

  6. js中addEventListener第三个参数涉及到的事件捕获与冒泡

    js中,我们可以给一个dom对象添加监听事件,函数就是 addEventListener("click",function(){},true); 很容易理解,第一个参数是事件类型, ...

  7. [刷题]算法竞赛入门经典(第2版) 5-13/UVa822 - Queue and A

    题意:模拟客服MM,一共有N种话题,每个客服MM支持处理其中的i个(i < N),处理的话题还有优先级.为了简化流程方便出题,设每个话题都是每隔m分钟来咨询一次.现知道每个话题前来咨询的时间.间 ...

  8. Spring Cloud 注册中心Eureka

    一.简介 最近在看Spring Cloud微服务,接下来的时间和大家一起分享我所看到的,公司现在用的是dubbo ,之后有时间也去了解了解dubbo的源码.与dubbo相比较,Spring Cloud ...

  9. iOS textfield 限制输入字数长度

    iOS textfield限制输入的最大长度 [self.textFiled addTarget:self action:@selector(textFieldDidChange:) forContr ...

  10. VUE依赖webpack分别给开发环境和生产环境配置不同的常量值并在项目中动态引用

    当在开发和产品上线的时候,我们经常会遇到在同一个地方由于环境的不同而地址也不同的情况,这时候如果在代码中将该地址写死,那势必会造成上线时手动改动,多人开发及多处使用该地址难以维护等一系列问题,为避免这 ...