文档章节

为什么加个注解@Transtaional就可以保证事务的一致性和完整性?

architect刘源源
 architect刘源源
发布于 06/16 09:58
字数 2306
阅读 114
收藏 0
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">

	<context:component-scan base-package="com.atguigu.book_xml"></context:component-scan>
	
	<!-- 引入属性文件 -->
	<context:property-placeholder location="db.properties"/>

	<!-- 创建数据源 -->
	<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
		<property name="driverClassName" value="${jdbc.driver}"></property>
		<property name="url" value="${jdbc.url}"></property>
		<property name="username" value="${jdbc.username}"></property>
		<property name="password" value="${jdbc.password}"></property>
	</bean>

	<!-- 通过数据源配置JdbcTemplate -->
	<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
		<property name="dataSource" ref="dataSource"></property>
	</bean>
	
	<!-- 配置事务管理器,不管是用注解方式或xml方式配置事务,一定要有DataSourceTransactionManager事务管理器的支持 -->
	<bean id="dataSourceTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource"></property>
	</bean>
	
	<!-- 配置事务通知 -->
	<tx:advice id="tx" transaction-manager="dataSourceTransactionManager">
		<tx:attributes>
			<!-- 在设置好的切入点表达式下再次进行事务设置 -->
			<tx:method name="buyBook"/>
			<tx:method name="checkOut"/>
			
			<!-- 只有select开头的方法才会被事务处理 -->
			<tx:method name="select*" read-only="true"/>
			<tx:method name="insert*"/>
			<tx:method name="update*"/>
			<tx:method name="delete*"/>
			
			<tx:method name="*"/>
			
		</tx:attributes>
	</tx:advice>

	<!-- 配置切入点表达式 -->
	<aop:config>
		<aop:pointcut expression="execution(* com.atguigu.book_xml.service.impl.*.*(..))" id="pointCut"/>
		<aop:advisor advice-ref="tx" pointcut-ref="pointCut"/>
	</aop:config>
	
</beans>

在xml里面定义了数据源bean,数据源bean又被事务管理器bean锁依赖,这时候用的数据源连接对象connection就是同一个,spring管理对象默认为单例

package com.atguigu.book.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import com.atguigu.book.service.BookService;
import com.atguigu.book.service.Cashier;

@Controller
public class BookController {

	@Autowired
	private BookService service;
	
	@Autowired
	private Cashier cashier;
	
	public void buyBook() {
		service.buyBook("1", "1001");
	}
	
	public void checkOut() {
		List<String> bids = new ArrayList<>();
		bids.add("1");
		bids.add("2");
		cashier.checkOut("1001", bids);
	}
	
}
package com.atguigu.book.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.atguigu.book.service.BookService;
import com.atguigu.book.service.Cashier;

@Service
@Transactional
public class CashierServiceImpl implements Cashier {

	@Autowired
	private BookService service;
	
	@Override
	public void checkOut(String uid, List<String> bids) {
		for (String bid : bids) {
			service.buyBook(bid, uid);
		}
	}

}
package com.atguigu.book.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.atguigu.book.dao.BookDao;
import com.atguigu.book.exception.MyException;
import com.atguigu.book.service.BookService;

@Service
//@Transactional
public class BookServiceImpl implements BookService {

	@Autowired
	private BookDao dao;
	
	/**
	 * @Transactional:对方法中所有的操作作为一个事务进行管理
	 * 在方法上使用,只对方法有效果
	 * 在类上使用,对类中所有的方法都有效果
	 * @Transactional中可以设置的属性:
	 * 
	 * propagation:A方法和B方法都有事务,当A在调用B时,会将A中的事务传播给B方法,B方法对于事务的处理方式就是事务的传播行为
	 * Propagation.REQUIRED:必须使用调用者的事务
	 * Propagation.REQUIRES_NEW:将调用者的事务挂起,不使用调用者的事务,使用新的事务进行处理
	 * 
	 * isolation:事务的隔离级别,在并发的情况下,操作数据的一种规定
	 * 			读未提交:脏读   1
	 * 			读已提交:不可重复读   2
	 * 			可重复读:幻读   4
	 * 			串行化:性能低,消耗大   8
	 * 
	 * 
	 * timeout:在事务强制回滚前最多可以执行(等待)的时间
	 * 
	 * readOnly:指定当前事务中的一系列的操作是否为只读
	 * 若设置为只读,不管事务中有没有写的操作,mysql都会在请求访问数据的时候,不加锁,提高性能
	 * 但是如果有写操作的情况,建议一定不能设置只读
	 * 
	 * rollbackFor|rollbackForClassName|noRollbackFor|noRollbackForClassName:设置事务回滚的条件
	 */
	
	@Transactional(propagation=Propagation.REQUIRES_NEW, timeout=3, noRollbackFor= {NullPointerException.class, MyException.class})
	public void buyBook(String bid, String uid) {
		/*try {
			Thread.sleep(5000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}*/
		Integer price = dao.selectPrice(bid);
		dao.updateSt(bid);
		dao.updateBalance(uid, price);
	}
}
package com.atguigu.book.dao.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import com.atguigu.book.dao.BookDao;
import com.atguigu.book.exception.MyException;

@Repository
public class BookDaoImpl implements BookDao {

	@Autowired
	private JdbcTemplate jdbcTemplate;

	@Override
	public Integer selectPrice(String bid) {
		Integer price = jdbcTemplate.queryForObject("select price from book where bid = ?", new Object[] {bid}, Integer.class);
		return price;
	}

	@Override
	public void updateSt(String bid) {
		//获取该书籍的库存
		Integer st = jdbcTemplate.queryForObject("select st from stock where sid = ?", new Object[] {bid}, Integer.class);
		if(st <= 0) {
			throw new RuntimeException();
		}else {
			jdbcTemplate.update("update stock set st = st -1 where sid = ?", bid);
		}
		
	}

	@Override
	public void updateBalance(String uid, Integer price) {
		Integer balance = jdbcTemplate.queryForObject("select balance from money where uid = ?", new Object[] {uid}, Integer.class);
		if(balance < price) {
			throw new MyException("余额不足");
		}else {
			jdbcTemplate.update("update money set balance = balance - ? where uid = ?", price, uid);
		}
	}
	
	
	
}

当然我也可以定义一个ThreadLocal<Connection> connection 

package com.atguigu.util;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;

import javax.sql.DataSource;

import com.alibaba.druid.pool.DruidDataSourceFactory;
/**
 * 获取连接和释放连接的工具类
 * @author Chunsheng Zhang
 *
 */
public class JDBCUtils {
	private static DataSource dataSource;
	
	/**
	 * ThreadLocal
	 * 		get()
	 * 		set()
	 *      remove()
	 */
	private static ThreadLocal<Connection> threadLocal = new ThreadLocal<>();
	
	static {
		try {
			//1、读取druip.properties文件
			Properties pro = new Properties();
			pro.load(JDBCUtils.class.getClassLoader().getResourceAsStream("druid.properties"));
			
			//2、连接连接池
			dataSource = DruidDataSourceFactory.createDataSource(pro);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	//获取连接
	public static Connection getConnection() {
		Connection connection = threadLocal.get();
		try {
			if(connection == null) {
				connection = dataSource.getConnection();
				threadLocal.set(connection);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return connection;
	}
//	public static Connection getConnection() {
//		Connection connection = null;
//		try {
//			connection = dataSource.getConnection();
//		} catch (SQLException e) {
//			e.printStackTrace();
//		}
//		return connection;
//	}

	//释放连接
	public static void releaseConnection() {
		Connection connection = threadLocal.get();
		if(connection != null) {
			try {
				connection.close();
				threadLocal.remove();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}
//	public static void releaseConnection(Connection connection) {
//		if(connection != null) {
//			try {
//				connection.close();
//			} catch (SQLException e) {
//				e.printStackTrace();
//			}
//		}
//	}
}
package com.atguigu.filter;

import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.atguigu.util.JDBCUtils;

/**
 * Servlet Filter implementation class TransactionFilter
 */
public class TransactionFilter extends HttpFilter {

	/**
	 * 1. 处理异常
	 * 2. 统一处理事务
	 */
	@Override
	public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
			throws IOException, ServletException {
		Connection connection = JDBCUtils.getConnection();
		try {
			//开启事务
			connection.setAutoCommit(false);
			//放行
			chain.doFilter(request, response);
			//无异常,提交事务
			connection.commit();
		} catch (Exception e) {
			//有异常,回滚事务
			try {
				connection.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
			response.sendRedirect(request.getContextPath()+"/pages/error/transaction_error.jsp");
		}finally {
			//释放Connection
			JDBCUtils.releaseConnection();
		}
		
	}
       
   

}
package com.atguigu.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.atguigu.bean.Cart;
import com.atguigu.bean.User;
import com.atguigu.service.OrderService;
import com.atguigu.service.impl.OrderServiceImpl;

/**
 * Servlet implementation class OrderServlet
 */
public class OrderServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
       
	private OrderService orderService = new OrderServiceImpl();
	
	protected void checkout(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//取值
		HttpSession session = request.getSession();
		Cart cart = (Cart)session.getAttribute("cart");
		User user  = (User)session.getAttribute("user");
		//调用service
		String orderId = orderService.createOrder(cart, user);
		session.setAttribute("orderId", orderId);
		//跳转
		response.sendRedirect(request.getContextPath()+"/pages/cart/checkout.jsp");
	}

}
package com.atguigu.service.impl;

import java.util.Date;
import java.util.List;

import com.atguigu.bean.Book;
import com.atguigu.bean.Cart;
import com.atguigu.bean.CartItem;
import com.atguigu.bean.Order;
import com.atguigu.bean.OrderItem;
import com.atguigu.bean.User;
import com.atguigu.dao.BookDao;
import com.atguigu.dao.OrderDao;
import com.atguigu.dao.OrderItemDao;
import com.atguigu.dao.impl.BookDaoImpl;
import com.atguigu.dao.impl.OrderDaoImpl;
import com.atguigu.dao.impl.OrderItemDaoImpl;
import com.atguigu.service.OrderService;
import com.atguigu.util.JDBCUtils;

public class OrderServiceImpl implements OrderService {

	private OrderDao orderDao = new OrderDaoImpl();
	private OrderItemDao orderItemDao = new OrderItemDaoImpl();
	private BookDao bookDao = new BookDaoImpl();
	/**
	 * * 去结账createOrder
	 * 		1. 生成订单
	 * 		2. 生成订单详情
	 * 		3. 更改相应book的库存和销量
	 * 		4. 清空购物车
	 * 
	 * * 批处理优化结账
	 * 		 * 1. BaseDao:添加batchUpdate()
	 * 			* queryRunner.batch(connection, sql, params);
	 * 			* params:Object[][]
	 * 			* 一维:次数
	 * 			* 二维:参数
			 * 2. OrderItemDao添加批处理接口
			 * 3. BookDao添加批处理接口
			 * 4. OrderServiceImpl调用dao批处理接口
			 * 		* Object[][] orderItemParams = new Object[cartItems.size()][];
					  Object[][] bookParams = new Object[cartItems.size()][];
					* orderItemParams[i] = new Object[]{参数的顺序};
	    * 使用事务优化结账
		 	* 开启事务:connection.setAutoCommit(false);|commit() rollback()
		 		1. 共用同一个connetion
		 			* ThreadLocal管理Connection
		 			* 删除BaseDao中的JDBCUtils.releaseConnection(connection);
		 		2. 统一处理异常(Filter)
		 			* 抛出BaseDao和BaseServlet中的异常,统一在Filter中处理
		 			* 统一开启事务,提交|回滚事务。
		
	 */
	@Override
	public String createOrder(Cart cart, User user) {
		//1. 生成订单
		//orderId=时间戳+userid
		String orderId = System.currentTimeMillis()+""+user.getId();		//null.
		orderDao.insertOrder(new Order(orderId, new Date(), cart.getTotalCount(),
				cart.getTotalAmount(), 0, user.getId()));
		
		//获取所有购物项
		List<CartItem> cartItems = cart.getCartItems();
		//OrderItem的二维参数
		Object[][] orderItemParams = new Object[cartItems.size()][];
		Object[][] bookParams = new Object[cartItems.size()][];
		
		//遍历购物项,添加到订单详情
		for (int i=0;i<cartItems.size();i++) {
			//2. 生成订单详情
			CartItem cartItem = cartItems.get(i);
			Book book = cartItem.getBook();
			int count = cartItem.getCount();
//			orderItemDao.insertOrderItem(new OrderItem(null, count,
//					cartItem.getAmount(), book.getTitle(), book.getAuthor(),
//					book.getPrice(), book.getImgPath(), orderId));
			//orderItemParams第二维赋值
			//`count`,amount,title,author,price,img_path,order_id
			orderItemParams[i] = new Object[] {count,
					cartItem.getAmount(), book.getTitle(), book.getAuthor(),
					book.getPrice(), book.getImgPath(), orderId};
			//3. 更改相应book的库存和销量
			int stock = book.getStock()-count;	//计算最终的库存
			int sales = book.getSales()+count;  //计算最终的销量
			//sales=?,stock=? where id=?
			bookParams[i] = new Object[] {sales,stock,book.getId()};
//			bookDao.updateBook(stock, sales, book.getId());
		}
		
		orderItemDao.insertOrderItem(orderItemParams);
		bookDao.updateBook(bookParams);
		
		//4. 清空购物车
		cart.emptyCart();
		return orderId;
	}

}
package com.atguigu.dao.impl;

import com.atguigu.bean.OrderItem;
import com.atguigu.dao.BaseDao;
import com.atguigu.dao.OrderItemDao;

public class OrderItemDaoImpl extends BaseDao<OrderItem> implements OrderItemDao {

	@Override
	public void insertOrderItem(OrderItem orderItem) {
		String sql = "INSERT INTO order_item(`count`,amount,title,author,price,img_path,order_id) VALUES(?,?,?,?,?,?,?)";
		this.update(sql, orderItem.getCount(),orderItem.getAmount(),orderItem.getTitle(),orderItem.getAuthor(),orderItem.getPrice(),orderItem.getImgPath(),orderItem.getOrderId());
	}

	/**
	 * 1. BaseDao:添加batchUpdate()
	 * 		* queryRunner.batch(connection, sql, params);
	 * 		* params:Object[][]
	 * 			* 一维:次数
	 * 			* 二维:参数
	 * 2. OrderItemDao添加批处理接口
	 * 3. BookDao添加批处理接口
	 * 4. OrderServiceImpl调用dao批处理接口
	 * 		* Object[][] orderItemParams = new Object[cartItems.size()][];
			  Object[][] bookParams = new Object[cartItems.size()][];
			* orderItemParams[i] = new Object[]{参数的顺序};
	 * 		
	 */
	@Override
	public void insertOrderItem(Object[][] params) {
		String sql = "INSERT INTO order_item(`count`,amount,title,author,price,img_path,order_id) VALUES(?,?,?,?,?,?,?)";
		this.batchUpdate(sql, params);
	}

}
package com.atguigu.dao.impl;

import java.util.List;

import com.atguigu.bean.Book;
import com.atguigu.bean.Page;
import com.atguigu.dao.BaseDao;
import com.atguigu.dao.BookDao;

public class BookDaoImpl extends BaseDao<Book> implements BookDao {

	@Override
	public List<Book> getAllBooks() {
		String sql = "SELECT id,title,author,price,sales,stock,img_path FROM books";
		return this.getBeanList(sql);
	}

	@Override
	public void addBook(Book book) {
		String sql = "insert into books(title,author,price,sales,stock,img_path) values(?,?,?,?,?,?)";
		this.update(sql, book.getTitle(),book.getAuthor(),book.getPrice(),book.getSales(),book.getStock(),book.getImgPath());
	}

	@Override
	public void delBookById(String id) {
		String sql = "delete from books where id = ?";
		this.update(sql, id);
	}

	@Override
	public Book getBookById(String id) {
		String sql = "SELECT id,title,author,price,sales,stock,img_path FROM books WHERE id = ?";
		return this.getBean(sql, id);
	}

	@Override
	public void updateBook(Book book) {
		String sql = "update books set title=?,author=?,price=?,sales=?,stock=? where id=?";
		this.update(sql, book.getTitle(),book.getAuthor(),book.getPrice(),book.getSales(),book.getStock(),book.getId());
	}
	@Override
	public void updateBook(int stock, int sales, int id) {
		String sql = "update books set sales=?,stock=? where id=?";
		this.update(sql,sales,stock,id);
	}
	@Override
	public void updateBook(Object[][] params) {
		String sql = "update books set sales=?,stock=? where id=?";
		this.batchUpdate(sql,params);
	}
	@Override
	public Page<Book> getBooksByPage(Page<Book> page) {
		//page:pageNo PAGE_SIZE totalPageNo
		//dao:totalRecord
		String sql = "select count(*) from books";
		int count = Integer.parseInt(this.getSingeValue(sql)+"");  //long(int) Integer.parse
		//将totalRecord赋值
		page.setTotalRecord(count);
//		System.out.println("record:"+page.getTotalRecord());
//		System.out.println("pageNo:"+page.getTotalPageNo());
		//dao:list
		String sql2 = "SELECT id,title,author,price,sales,stock,img_path "
				+ "FROM books "
				+ "WHERE 1=1 "
				+ "LIMIT ?,?";
		List<Book> list = this.getBeanList(sql2, (page.getPageNo()-1)*Page.PAGE_SIZE,Page.PAGE_SIZE);
		//将list存放到page中
		page.setList(list);
		return page;
	}

	@Override
	public Page<Book> getBooksByPageAndPrice(Page<Book> page,double min,double max) {
		String sql = "SELECT count(*) "
				+ "FROM books "
				+ "WHERE 1=1 "
				+ "AND price BETWEEN ? AND ?";
		int count = Integer.parseInt(this.getSingeValue(sql, min,max)+"");  //long(int) Integer.parse
		//将totalRecord赋值
		page.setTotalRecord(count);
		//dao:list
		String sql2 = "SELECT id,title,author,price,sales,stock,img_path "
				+ "FROM books "
				+ "WHERE 1=1 "
				+ "AND price BETWEEN ? AND ? "
				+ "LIMIT ?,?";
		List<Book> list = this.getBeanList(sql2, min,max,(page.getPageNo()-1)*Page.PAGE_SIZE,Page.PAGE_SIZE);
		//将list存放到page中
		page.setList(list);
		return page;
	}


	
	
}
package com.atguigu.dao.impl;

import com.atguigu.bean.Order;
import com.atguigu.dao.BaseDao;
import com.atguigu.dao.OrderDao;

public class OrderDaoImpl extends BaseDao<Order> implements OrderDao {

	@Override
	public void insertOrder(Order order) {
		String sql = "INSERT INTO orders(id,order_time,total_count,total_amount,state,user_id) VALUES(?,?,?,?,?,?)";
		this.update(sql, order.getId(),order.getOrderTime(),order.getTotalCount(),order.getTotalAmount(),order.getState(),order.getUserId());
	}

}

 

© 著作权归作者所有

architect刘源源

architect刘源源

粉丝 167
博文 554
码字总数 934264
作品 0
浦东
程序员
私信 提问
ServiceComb数据一致性解决方案Saga演进介绍

传统的单体应用的微服务化改造过程中大多会面临数据库拆分,故而原来由数据库保证的数据一致性也一定面临重新设计和实现,此时需要引入分布式数据一致性方案来解决。常见的解决方案主要有2PC...

dev_csdn
2018/04/08
0
0
数据库ACID整理

一、事务 定义:所谓事务,它是一个操作序列,这些操作要么都执行,要么都不执行,它是一个不可分割的工作单位。 准备工作:为了说明事务的ACID原理,我们使用银行账户及资金管理的案例进行分...

John
2017/11/27
0
0
从银行转账失败到分布式事务:总结与思考

原文出处:xybaby 思考这个问题的初衷,是有一次给朋友转账,结果我的钱被扣了,朋友没收到钱。而我之前一直认为银行转账一定是由事务保证强一致性的,于是学习、总结了一下分布式事务的各种...

xybaby
2017/10/24
0
0
漫谈事务与分布式事务(1)- 理解 ACID

最近看了一点资料,准备写一个大话题。 事务,是所有数据库讲义中最核心的话题。它本质上是一系列连续的,逻辑相关的数据库操作的组合。随便翻开一本书,都会告诉你,事务必须满足下面四个属...

长源
2014/03/11
0
0
Spring事务的理解

事务的基本原理: Spring事务的本质其实就是数据库对事务的支持,没有数据库的事务支持,spring是无法提供事务功能的。对于纯JDBC操作数据库,想要用到事务,可以按照以下步骤进行: 获取连接...

风格若干
2016/08/17
77
0

没有更多内容

加载失败,请刷新页面

加载更多

Spring boot 静态资源访问

0. 两个配置 spring.mvc.static-path-patternspring.resources.static-locations 1. application中需要先行的两个配置项 1.1 spring.mvc.static-path-pattern 这个配置项是告诉springboo......

moon888
今天
3
0
hash slot(虚拟桶)

在分布式集群中,如何保证相同请求落到相同的机器上,并且后面的集群机器可以尽可能的均分请求,并且当扩容或down机的情况下能对原有集群影响最小。 round robin算法:是把数据mod后直接映射...

李朝强
今天
4
0
Kafka 原理和实战

本文首发于 vivo互联网技术 微信公众号 https://mp.weixin.qq.com/s/bV8AhqAjQp4a_iXRfobkCQ 作者简介:郑志彬,毕业于华南理工大学计算机科学与技术(双语班)。先后从事过电子商务、开放平...

vivo互联网技术
今天
20
0
java数据类型

基本类型: 整型:Byte,short,int,long 浮点型:float,double 字符型:char 布尔型:boolean 引用类型: 类类型: 接口类型: 数组类型: Byte 1字节 八位 -128 -------- 127 short 2字节...

audience_1
今天
9
0
太全了|万字详解Docker架构原理、功能及使用

一、简介 1、了解Docker的前生LXC LXC为Linux Container的简写。可以提供轻量级的虚拟化,以便隔离进程和资源,而且不需要提供指令解释机制以及全虚拟化的其他复杂性。相当于C++中的NameSpa...

Java技术剑
今天
27
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部