在领域模型中,类与类之间最普通的关系就是关联关系。

在UML中,关联是有方向的:

  例如:Customer与Order,一个用户能发出多个订单,而一个订单只能属于一个用户。

  • 单向关联

  1)从Order到Customer的关联是多对一关联;

定义Customer:

 package com.dx.hibernate.onetomany;

 public class Customer {
private Integer customerId;
private String customerName; public Customer() {
} public Customer(String customerName) {
super();
this.customerName = customerName;
} public Integer getCustomerId() {
return customerId;
} public void setCustomerId(Integer customerId) {
this.customerId = customerId;
} public String getCustomerName() {
return customerName;
} public void setCustomerName(String customerName) {
this.customerName = customerName;
}
}
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 2017-5-24 12:02:56 by Hibernate Tools 3.5.0.Final -->
<hibernate-mapping>
<class name="com.dx.hibernate.onetomany.Customer" table="CUSTOMER">
<id name="customerId" type="java.lang.Integer">
<column name="CUSTOMER_ID" />
<generator class="native" />
</id>
<property name="customerName" type="java.lang.String">
<column name="CUSTOMER_NAME" />
</property>
</class>
</hibernate-mapping>

定义Order:

package com.dx.hibernate.onetomany;

public class Order {
private Integer orderId;
private String orderName;
private Customer customer; public Integer getOrderId() {
return orderId;
} public void setOrderId(Integer orderId) {
this.orderId = orderId;
} public String getOrderName() {
return orderName;
} public void setOrderName(String orderName) {
this.orderName = orderName;
} public Customer getCustomer() {
return customer;
} public void setCustomer(Customer customer) {
this.customer = customer;
}
}
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 2017-5-24 12:02:56 by Hibernate Tools 3.5.0.Final -->
<hibernate-mapping>
<class name="com.dx.hibernate.onetomany.Order" table="ORDERS">
<id name="orderId" type="java.lang.Integer">
<column name="ORDER_ID" />
<generator class="assigned" />
</id>
<property name="orderName" type="java.lang.String">
<column name="ORDER_NAME" />
</property>
<many-to-one name="customer" class="com.dx.hibernate.onetomany.Customer">
<column name="CUSTOMER_ID" />
</many-to-one>
</class>
</hibernate-mapping>

初始化项目时,生成sql语句:

Hibernate: 

create table CUSTOMER (
  CUSTOMER_ID integer not null auto_increment,
  CUSTOMER_NAME varchar(255),
  primary key (CUSTOMER_ID)
) engine=InnoDB
Hibernate: create table ORDERS (
  ORDER_ID integer not null auto_increment,
  ORDER_NAME varchar(255),
  CUSTOMER_ID integer,
  primary key (ORDER_ID)
) engine=InnoDB
Hibernate: alter table ORDERS
add constraint FKkdbly1ij6f4kqh378kfne6ilx
foreign key (CUSTOMER_ID)
references CUSTOMER (CUSTOMER_ID)

测试代码1:

package com.dx.hibernate.onetomany;

import static org.junit.Assert.fail;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.boot.Metadata;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.model.naming.ImplicitNamingStrategyComponentPathImpl;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.junit.After;
import org.junit.Before;
import org.junit.Test; public class TestMain {
private SessionFactory sessionFactory = null;
private Session session = null;
private Transaction transaction = null; @Before
public void init() {
StandardServiceRegistry standardRegistry = new StandardServiceRegistryBuilder().configure().build();
Metadata metadata = new MetadataSources(standardRegistry).getMetadataBuilder().applyImplicitNamingStrategy(ImplicitNamingStrategyComponentPathImpl.INSTANCE).build(); sessionFactory = metadata.getSessionFactoryBuilder().build();
session = sessionFactory.getCurrentSession();
transaction = session.beginTransaction();
} @Test
public void test() {
Customer customer = new Customer("customer1");
Order order1 = new Order("order1", customer);
Order order2 = new Order("order2", customer); session.save(customer);
session.save(order1);
session.save(order2);
} @After
public void destory() {
transaction.commit();
session.close();
sessionFactory.close();
}
}

测试执行sql:

Hibernate:
insert
into
CUSTOMER
(CUSTOMER_NAME)
values
(?)
Hibernate:
insert
into
ORDERS
(ORDER_NAME, CUSTOMER_ID)
values
(?, ?)
Hibernate:
insert
into
ORDERS
(ORDER_NAME, CUSTOMER_ID)
values
(?, ?)

测试代码2:

    @Test
public void test() {
Order order = (Order) session.get(Order.class, 1); System.out.println(order.getOrderName());
System.out.println(order.getCustomer().getCustomerName());
}

测试结果:

测试通过,且查询语句为:

Hibernate:
select
order0_.ORDER_ID as ORDER_ID1_1_0_,
order0_.ORDER_NAME as ORDER_NA2_1_0_,
order0_.CUSTOMER_ID as CUSTOMER3_1_0_
from
ORDERS order0_
where
order0_.ORDER_ID=?
order1
Hibernate:
select
customer0_.CUSTOMER_ID as CUSTOMER1_0_0_,
customer0_.CUSTOMER_NAME as CUSTOMER2_0_0_
from
CUSTOMER customer0_
where
customer0_.CUSTOMER_ID=?
customer1

测试代码3:

    @Test
public void test() {
Order order = (Order) session.get(Order.class, 1); System.out.println(order.getOrderName());
//System.out.println(order.getCustomer().getCustomerName()); session.close(); System.out.println(order.getCustomer().getCustomerName());
}

测试结果不通过,执行sql语句:

Hibernate:
select
order0_.ORDER_ID as ORDER_ID1_1_0_,
order0_.ORDER_NAME as ORDER_NA2_1_0_,
order0_.CUSTOMER_ID as CUSTOMER3_1_0_
from
ORDERS order0_
where
order0_.ORDER_ID=?
order1

测试4:

修改Order.hbm.xml

        <many-to-one name="customer" class="com.dx.hibernate.onetomany.Customer" fetch="join">
<column name="CUSTOMER_ID" />
</many-to-one>

测试代码:

         Order order = (Order) session.get(Order.class, 1);

         System.out.println(order.getOrderName());
System.out.println(order.getCustomer().getCustomerName());

测试通过,打印的sql语句:

Hibernate:
select
order0_.ORDER_ID as ORDER_ID1_1_0_,
order0_.ORDER_NAME as ORDER_NA2_1_0_,
order0_.CUSTOMER_ID as CUSTOMER3_1_0_,
customer1_.CUSTOMER_ID as CUSTOMER1_0_1_,
customer1_.CUSTOMER_NAME as CUSTOMER2_0_1_
from
ORDERS order0_
left outer join
CUSTOMER customer1_
on order0_.CUSTOMER_ID=customer1_.CUSTOMER_ID
where
order0_.ORDER_ID=?

测试代码5:

修改Order.hbm.xml

        <many-to-one name="customer" class="com.dx.hibernate.onetomany.Customer" fetch="join">
<column name="CUSTOMER_ID" />
</many-to-one>

测试代码:

         Order order = (Order) session.get(Order.class, 1);

         System.out.println(order.getOrderName());
System.out.println(order.getCustomer().getCustomerName()); session.close(); System.out.println(order.getCustomer().getCustomerName());

测试不通过。

  2)从Customer到Order的关联是一对多关联。

Order.java

 package com.dx.hibernate.onetomany;

 public class Order {
private Integer orderId;
private String orderName; public Order() {
super();
} public Order(String orderName) {
super();
this.orderName = orderName;
} public Integer getOrderId() {
return orderId;
} public void setOrderId(Integer orderId) {
this.orderId = orderId;
} public String getOrderName() {
return orderName;
} public void setOrderName(String orderName) {
this.orderName = orderName;
} }

Order.hbm.xml

 <?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 2017-5-25 22:09:21 by Hibernate Tools 3.5.0.Final -->
<hibernate-mapping>
<class name="com.dx.hibernate.onetomany.Order" table="ORDERS">
<id name="orderId" type="java.lang.Integer">
<column name="ORDER_ID" />
<generator class="native" />
</id>
<property name="orderName" type="java.lang.String">
<column name="ORDER_NAME" />
</property>
</class>
</hibernate-mapping>

Customer.java

 package com.dx.hibernate.onetomany;

 import java.util.ArrayList;
import java.util.List; public class Customer {
private Integer customerId;
private String customerName;
private List<Order> orders = new ArrayList<Order>(); public Customer() {
} public Customer(String customerName) {
super();
this.customerName = customerName;
} public Integer getCustomerId() {
return customerId;
} public void setCustomerId(Integer customerId) {
this.customerId = customerId;
} public String getCustomerName() {
return customerName;
} public void setCustomerName(String customerName) {
this.customerName = customerName;
} public List<Order> getOrders() {
return orders;
} public void setOrders(List<Order> orders) {
this.orders = orders;
}
}

Customer.hbm.xml

 <?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 2017-5-25 22:09:21 by Hibernate Tools 3.5.0.Final -->
<hibernate-mapping>
<class name="com.dx.hibernate.onetomany.Customer" table="CUSTOMER">
<id name="customerId" type="java.lang.Integer">
<column name="CUSTOMER_ID" />
<generator class="native" />
</id>
<property name="customerName" type="java.lang.String">
<column name="CUSTOMER_NAME" />
</property>
<list name="orders" inverse="false" table="ORDERS" lazy="true">
<key>
<column name="CUSTOMER_ID" />
</key>
<list-index></list-index>
<one-to-many class="com.dx.hibernate.onetomany.Order" />
</list>
</class>
</hibernate-mapping>

TestMain.java

package com.dx.hibernate.onetomany;

import static org.junit.Assert.fail;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.boot.Metadata;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.model.naming.ImplicitNamingStrategyComponentPathImpl;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.query.Query;
import org.junit.After;
import org.junit.Before;
import org.junit.Test; public class TestMain {
private SessionFactory sessionFactory = null;
private Session session = null;
private Transaction transaction = null; @Before
public void init() {
StandardServiceRegistry standardRegistry = new StandardServiceRegistryBuilder().configure().build();
Metadata metadata = new MetadataSources(standardRegistry).getMetadataBuilder().applyImplicitNamingStrategy(ImplicitNamingStrategyComponentPathImpl.INSTANCE).build(); sessionFactory = metadata.getSessionFactoryBuilder().build();
session = sessionFactory.getCurrentSession();
transaction = session.beginTransaction();
} @SuppressWarnings("deprecation")
@Test
public void test() {
Order order1 = new Order("order1");
Order order2 = new Order("order2");
Customer customer = new Customer("customer1");
customer.getOrders().add(order1);
customer.getOrders().add(order2); session.save(customer);
session.save(order1);
session.save(order2); Customer customerFetch = (Customer) session.get(Customer.class, 1); System.out.println(customerFetch.getCustomerName());
System.out.println(customerFetch.getOrders().size()); } @After
public void destory() {
transaction.commit();
session.close();
sessionFactory.close();
}
}

测试结果:通过,打印信息如下:

INFO: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@320e400] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
Hibernate: create table CUSTOMER (
CUSTOMER_ID integer not null auto_increment,
CUSTOMER_NAME varchar(255),
primary key (CUSTOMER_ID)
) engine=InnoDB
Hibernate: create table ORDERS (
ORDER_ID integer not null auto_increment,
ORDER_NAME varchar(255),
CUSTOMER_ID integer,
orders_ORDER integer,
primary key (ORDER_ID)
) engine=InnoDB
Hibernate: alter table ORDERS
add constraint FKkdbly1ij6f4kqh378kfne6ilx
foreign key (CUSTOMER_ID)
references CUSTOMER (CUSTOMER_ID)
Hibernate:
insert
into
CUSTOMER
(CUSTOMER_NAME)
values
(?)
Hibernate:
insert
into
ORDERS
(ORDER_NAME)
values
(?)
Hibernate:
insert
into
ORDERS
(ORDER_NAME)
values
(?)
customer1
2
Hibernate:
update
ORDERS
set
CUSTOMER_ID=?,
orders_ORDER=?
where
ORDER_ID=?
Hibernate:
update
ORDERS
set
CUSTOMER_ID=?,
orders_ORDER=?
where
ORDER_ID=?
  • 双向关联

Order.java

 package com.dx.hibernate.onetomany;

 public class Order {
private Integer orderId;
private String orderName;
private Customer customer; public Order() {
super();
} public Order(String orderName) {
super();
this.orderName = orderName;
} public Integer getOrderId() {
return orderId;
} public void setOrderId(Integer orderId) {
this.orderId = orderId;
} public String getOrderName() {
return orderName;
} public void setOrderName(String orderName) {
this.orderName = orderName;
} public Customer getCustomer() {
return customer;
} public void setCustomer(Customer customer) {
this.customer = customer;
} }

Order.hbm.xml

 <?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 2017-5-25 22:09:21 by Hibernate Tools 3.5.0.Final -->
<hibernate-mapping>
<class name="com.dx.hibernate.onetomany.Order" table="ORDERS">
<id name="orderId" type="java.lang.Integer">
<column name="ORDER_ID" />
<generator class="native" />
</id>
<property name="orderName" type="java.lang.String">
<column name="ORDER_NAME" />
</property>
<many-to-one name="customer" class="com.dx.hibernate.onetomany.Customer" lazy="proxy">
<column name="CUSTOMER_ID"></column>
</many-to-one>
</class>
</hibernate-mapping>

Customer.java

 package com.dx.hibernate.onetomany;

 import java.util.ArrayList;
import java.util.List; public class Customer {
private Integer customerId;
private String customerName;
private List<Order> orders = new ArrayList<Order>(); public Customer() {
} public Customer(String customerName) {
super();
this.customerName = customerName;
} public Integer getCustomerId() {
return customerId;
} public void setCustomerId(Integer customerId) {
this.customerId = customerId;
} public String getCustomerName() {
return customerName;
} public void setCustomerName(String customerName) {
this.customerName = customerName;
} public List<Order> getOrders() {
return orders;
} public void setOrders(List<Order> orders) {
this.orders = orders;
}
}

Customer.hbm.xml

 <?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 2017-5-25 22:09:21 by Hibernate Tools 3.5.0.Final -->
<hibernate-mapping>
<class name="com.dx.hibernate.onetomany.Customer" table="CUSTOMER">
<id name="customerId" type="java.lang.Integer">
<column name="CUSTOMER_ID" />
<generator class="native" />
</id>
<property name="customerName" type="java.lang.String">
<column name="CUSTOMER_NAME" />
</property>
<list name="orders" inverse="false" table="ORDERS" lazy="true">
<key>
<column name="CUSTOMER_ID" />
</key>
<list-index></list-index>
<one-to-many class="com.dx.hibernate.onetomany.Order" />
</list>
</class>
</hibernate-mapping>

测试1

 package com.dx.hibernate.onetomany;

 import static org.junit.Assert.fail;

 import java.util.List;

 import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.boot.Metadata;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.model.naming.ImplicitNamingStrategyComponentPathImpl;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.query.Query;
import org.junit.After;
import org.junit.Before;
import org.junit.Test; public class TestMain {
private SessionFactory sessionFactory = null;
private Session session = null;
private Transaction transaction = null; @Before
public void init() {
StandardServiceRegistry standardRegistry = new StandardServiceRegistryBuilder().configure().build();
Metadata metadata = new MetadataSources(standardRegistry).getMetadataBuilder().applyImplicitNamingStrategy(ImplicitNamingStrategyComponentPathImpl.INSTANCE).build(); sessionFactory = metadata.getSessionFactoryBuilder().build();
session = sessionFactory.getCurrentSession();
transaction = session.beginTransaction();
} @SuppressWarnings("deprecation")
@Test
public void test() {
Order order1 = new Order("order1");
Order order2 = new Order("order2");
Customer customer = new Customer("customer1");
customer.getOrders().add(order1);
customer.getOrders().add(order2); session.save(customer);
session.save(order1);
session.save(order2); Customer customerFetch = (Customer) session.get(Customer.class, 1); System.out.println(customerFetch.getCustomerName());
System.out.println(customerFetch.getOrders().size()); } @After
public void destory() {
transaction.commit();
session.close();
sessionFactory.close();
}
}

测试打印信息:

Hibernate: 

    create table CUSTOMER (
CUSTOMER_ID integer not null auto_increment,
CUSTOMER_NAME varchar(255),
primary key (CUSTOMER_ID)
) engine=InnoDB
Hibernate: create table ORDERS (
ORDER_ID integer not null auto_increment,
ORDER_NAME varchar(255),
CUSTOMER_ID integer,
orders_ORDER integer,
primary key (ORDER_ID)
) engine=InnoDB
Hibernate: alter table ORDERS
add constraint FKkdbly1ij6f4kqh378kfne6ilx
foreign key (CUSTOMER_ID)
references CUSTOMER (CUSTOMER_ID)
Hibernate:
insert
into
CUSTOMER
(CUSTOMER_NAME)
values
(?)
Hibernate:
insert
into
ORDERS
(ORDER_NAME, CUSTOMER_ID)
values
(?, ?)
Hibernate:
insert
into
ORDERS
(ORDER_NAME, CUSTOMER_ID)
values
(?, ?)
customer1
2
Hibernate:
update
ORDERS
set
CUSTOMER_ID=?,
orders_ORDER=?
where
ORDER_ID=?
Hibernate:
update
ORDERS
set
CUSTOMER_ID=?,
orders_ORDER=?
where
ORDER_ID=?

测试2:

    @Test
public void testUpdate(){
Customer customerFetch = (Customer) session.get(Customer.class, 1);
customerFetch.getOrders().listIterator().next().setOrderName("ABC");
}

测试输出:

Hibernate:
select
customer0_.CUSTOMER_ID as CUSTOMER1_0_0_,
customer0_.CUSTOMER_NAME as CUSTOMER2_0_0_
from
CUSTOMER customer0_
where
customer0_.CUSTOMER_ID=?
Hibernate:
select
orders0_.CUSTOMER_ID as CUSTOMER3_1_0_,
orders0_.ORDER_ID as ORDER_ID1_1_0_,
orders0_.orders_ORDER as orders_O4_0_,
orders0_.ORDER_ID as ORDER_ID1_1_1_,
orders0_.ORDER_NAME as ORDER_NA2_1_1_,
orders0_.CUSTOMER_ID as CUSTOMER3_1_1_
from
ORDERS orders0_
where
orders0_.CUSTOMER_ID=?
Hibernate:
update
ORDERS
set
ORDER_NAME=?,
CUSTOMER_ID=?
where
ORDER_ID=?

测试3:

    @Test
public void testRemove() {
Customer customerFetch = (Customer) session.get(Customer.class, 2);
Order order = customerFetch.getOrders().listIterator().next();
session.remove(order);
}

测试输出:

Hibernate:
select
customer0_.CUSTOMER_ID as CUSTOMER1_0_0_,
customer0_.CUSTOMER_NAME as CUSTOMER2_0_0_
from
CUSTOMER customer0_
where
customer0_.CUSTOMER_ID=?
Hibernate:
select
orders0_.CUSTOMER_ID as CUSTOMER3_1_0_,
orders0_.ORDER_ID as ORDER_ID1_1_0_,
orders0_.orders_ORDER as orders_O4_0_,
orders0_.ORDER_ID as ORDER_ID1_1_1_,
orders0_.ORDER_NAME as ORDER_NA2_1_1_,
orders0_.CUSTOMER_ID as CUSTOMER3_1_1_
from
ORDERS orders0_
where
orders0_.CUSTOMER_ID=?
Hibernate:
delete
from
ORDERS
where
ORDER_ID=?

Hibernate(六):映射一对多关联关系、双向一对多映射的更多相关文章

  1. (转)Hibernate框架基础——一对多关联关系映射

    http://blog.csdn.net/yerenyuan_pku/article/details/52746413 上一篇文章Hibernate框架基础——映射集合属性详细讲解的是值类型的集合(即 ...

  2. (转)Hibernate关联映射——一对多(多对一)

    http://blog.csdn.net/yerenyuan_pku/article/details/70152173 Hibernate关联映射——一对多(多对一) 我们以客户(Customer)与 ...

  3. 攻城狮在路上(壹) Hibernate(五)--- 映射一对多关联关系

    关联是有方向的,包含单向关联和双向关联.分别讨论.本文以客户Customer和订单Order来进行讨论:一个Customer有多个Order,每个Order对应一个Customer. Customer ...

  4. [原创]java WEB学习笔记82:Hibernate学习之路---映射 一对多关联关系,配置,CRUD方法测试及注意点

    本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...

  5. JPA学习笔记(8)——映射一对多关联关系

    一对多关联关系 本文有很多和多对一是一样的,因此不会写得非常具体. 有看不懂的.能够參考JPA学习笔记(7)--映射多对一关联关系 Order实体类 package com.jpa.helloworl ...

  6. Hibernate逍遥游记-第5章映射一对多-02双向(<set>、<key>、<one-to-many>、inverse、cascade="all-delete-orphan")

    1. <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hi ...

  7. Hibernate 集合映射 一对多多对一 inverse属性 + cascade级联属性 多对多 一对一 关系映射

    1 . 集合映射 需求:购物商城,用户有多个地址. // javabean设计 // javabean设计 public class User { private int userId; privat ...

  8. mybatis一对多关联关系映射

    mybatis一对多关联关系映射 一对多关联关系只需要在多的一方引入少的一方的主键作为外键即可.在实体类中就是反过来,在少的一方添加多的一方,声明一个List 属性名 作为少的一方的属性. 用户和订单 ...

  9. Hibernate关联映射及高级查询

    一.Hibernate中的关联关系 1.1.单向一对多关联关系 按照以下步骤配置hibernate中持久化类的一对多对象关联: (1).持久化类添加关联类的相关属性及getter/setter方法. ...

随机推荐

  1. Open source operational tools

    操作系统:Centos,Ubuntu,Redhat,suse,Freebsd 网站服务:nginx,apache,lighttpd,php,tomcat,resin 数据   库:MySQL,Mari ...

  2. 20165230 预备作业3 Linux安装及学习

    20165230 预备作业3 Linux安装及学习 安装Linux操作系统 通过学习实践基于VirtualBox虚拟机安装Ubuntu图文教程,开始了虚拟机的安装,根据教程按着步骤一步一步的完成. 遇 ...

  3. VMware安装Centos6.4及CentOS的基本设置

    1.vmware安装vmware tools实现与本地磁盘文件夹的共享 2.设置Centos网络 vmware采用nat方式.虚拟机网络使用虚拟网卡(VMware Network Adapter VM ...

  4. 用IDEA生成javadoc文档

    用IDEA生成javadoc文档 打开相应的选项面板 设置 -encoding是java代码编码,-charset是对生成文档所用的编码.-windowtitle就是对应html的<title& ...

  5. vue中$on与$emit的实际应用

    $on常用于监听自定义事件,触发后可传入参数 //监听event1事件 vm.$on('event1',function(msg){ console.log(msg) }) //触发event1自定义 ...

  6. webpack-dev-server 设置反向代理解决跨域问题

    一.设置代理的原因 现在对前端开发的要求越来越高,并且随着自动化以及模块化的 诞生,前后端开发模式越来越流行.后端只负责接口,前端负责数据展示.逻辑处理.但是前后端开发模式,有一个重要的问题,就是跨域 ...

  7. pyrhon多进程操作初探

    linux系统中提供了fork函数进行进程的创建,这个接口在函数返回上比较特殊,有两个返回值,一个是子进程返回值为0,一个是父进程返回值,值大于0,表是子进程的ID.如果小于0.则表示接口出错. py ...

  8. centos7 用工具nmtui更改网卡设置

    1.[root@cjh-db ~ 15:13:59]#nmtui

  9. 光环国际联合阿里云推出“AI智客计划”

    2018阿里巴巴云栖大会深圳峰会3月28日.29日在大中华喜来登酒店举行,阿里云全面展示智能城市.智能汽车.智能生活.智能制造等产业创新. 3月28日下午,以"深化产教融合,科技赋能育人才& ...

  10. Struts2 之 Action 类访问 WEB 资源

    接着上次博客的内容我继续分享我所学到的知识,和自己在学习过程中所遇到问题以及解决方案.当然,如果读者发现任何问题均可以在下方评论告知我,先谢! 在 Action 中访问 WEB 资源 web 资源 所 ...