Hibernate实战(第二版)笔记----第四章--映射持久化类

2024-06-17 05:48

本文主要是介绍Hibernate实战(第二版)笔记----第四章--映射持久化类,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

一、本章主要介绍了


实体类型: 


该类的实例有OID,一个实例对应表的一条记录,实例的OID就是该记录的主键。 
一个实例可以被多个其他实体对象共享引用。 有独立的生命周期。可以被单独持久化。 


值类型 :没有OID,不能被单独持久化,只能附属到一个依赖对象上,只能被依赖对象引用,有该依赖对象负责其生命周期。(没有OID就是没有主键,当然不能insert到表中了)。 


一句话: 


实体类型,在DB中代表一个表,一个实体代表一行记录;

值类型在DB中没有表,只代表一个column。 


对象模型(域模型)有具体的程序代码写成的,为了提高代码的重用性,可能会把域模型拆分定义成多个类,在这多个类中,那些包含了主键的成员的类就是entity,它的OID对应的就是表中的主键,它可以直接单独insert到表中;而那些只对应包含非主键的成员变量的类,就是值类.值类作为成员变量定义在entity类中,持久化entity类时,entity实例被保存成一个row,它的值类成员被保存成row的column。


几种键


键: 键是唯一标识一个实体的一个或者多个数据属性。在物理数据库中,键可以由表的一个或者多个列组成,它们的值唯一标识关系表中的一行。


复合键: 由两个或者多个属性组成的键。


自然键: 由现实世界中已经存在的属性组成的键。例如,美国公民被分配了一个唯一(不保证一定正确,但实际上非常接近唯一)的社会保险号(SSN)。如果隐私法允许的话,SSN可能被用作Person实体的自然键(假设组织的人员范围仅限于美国)。


代理键: 完全没有商业含义,通常由当下的系统自动生成,都是单键。


自然键: 已经真实存在的键,通常具有商业含义,比如身份证ID,护照编码等等,可以是单键,也可以是复合键。


候选键: 在逻辑数据模型中的实体类型可能具有0或多个候选键,简称为唯一标识(注解:某些人不主张在逻辑数据模型中标识候选键,因此没有固定标准)。例如,假设我们只涉及美国公民,那么SSN是Person实体类型的一个候选键,同时姓名与电话号码的组合(假设组合是唯一的)是第二个可能的候选键。这两个键都被称作候选键是因为它们是物理数据模型中主键、次键或者非键的候选目标。

主键: 实体类型的首选键。


备用键: 也就是次键,是表中行的另一个唯一标识。


外键: 在一个实体类型中表示另一个实体类型的主键或者次键的一个或多个属性。


详解介绍参考这:https://ask.hellobi.com/blog/rayshawn/3257



二、代码


一些实体类:




其中User类中使用了作为包级别元数据配置的Hibernate标识符生成器:


package org.jpwh.model.advanced;import org.jpwh.model.Constants;import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;@Entity
@Table(name = "USERS")
public class User {@Id@GeneratedValue(generator = Constants.ID_GENERATOR)protected Long id;public Long getId() {return id;}protected Address address;public Address getAddress() {return address;}public void setAddress(Address address) {this.address = address;}
}


ID_GENERATOR定义为:


/model/src/main/java/org/jpwh/model/package-info.java

@org.hibernate.annotations.GenericGenerator(name = "ID_GENERATOR",strategy = "enhanced-sequence",parameters = {@org.hibernate.annotations.Parameter(name = "sequence_name",value = "JPWH_SEQUENCE"),@org.hibernate.annotations.Parameter(name = "initial_value",value = "1000")
})
package org.jpwh.model;

而ItemBidSummary类则使用了子查询映射:

package org.jpwh.model.advanced;import javax.persistence.Entity;
import javax.persistence.Id;@Entity
@org.hibernate.annotations.Immutable
@org.hibernate.annotations.Subselect(value = "select i.ID as ITEMID, i.ITEM_NAME as NAME, " +"count(b.ID) as NUMBEROFBIDS " +"from ITEM i left outer join BID b on i.ID = b.ITEM_ID " +"group by i.ID, i.ITEM_NAME"
)// TODO Table names are case sensitive, Hibernate bug HHH-8430
@org.hibernate.annotations.Synchronize({"Item", "Bid"})
public class ItemBidSummary {@Idprotected Long itemId;protected String name;protected long numberOfBids;public ItemBidSummary() {}// Getter methods...public Long getItemId() {return itemId;}public String getName() {return name;}public long getNumberOfBids() {return numberOfBids;}// ...
}


测试类:


/examples/src/test/java/org/jpwh/test/advanced/MappedSubselect.java

package org.jpwh.test.advanced;import org.jpwh.env.JPATest;
import org.jpwh.model.advanced.Bid;
import org.jpwh.model.advanced.Item;
import org.jpwh.model.advanced.ItemBidSummary;
import org.testng.annotations.Test;import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.transaction.UserTransaction;
import java.math.BigDecimal;import static org.testng.Assert.assertEquals;//映射子查询
public class MappedSubselect extends JPATest {@Overridepublic void configurePersistenceUnit() throws Exception {configurePersistenceUnit("AdvancedPU");}@Testpublic void loadSubselectEntity() throws Exception {long ITEM_ID = storeItemAndBids();UserTransaction tx = TM.getUserTransaction();try {tx.begin();EntityManager em = JPA.createEntityManager();{ItemBidSummary itemBidSummary = em.find(ItemBidSummary.class, ITEM_ID);// select * from (//      select i.ID as ITEMID, i.ITEM_NAME as NAME, ...// ) where ITEMID = ?assertEquals(itemBidSummary.getName(), "AUCTION: Some item");}em.clear();{ // Hibernate将在查询之前同步正确的表Item item = em.find(Item.class, ITEM_ID);item.setName("New name");// 在检索标识符之前不刷新!// ItemBidSummary itemBidSummary = em.find(ItemBidSummary.class, ITEM_ID);// 如果同步表受影响,在查询之前自动刷新。Query query = em.createQuery("select ibs from ItemBidSummary ibs where ibs.itemId = :id");ItemBidSummary itemBidSummary =(ItemBidSummary)query.setParameter("id", ITEM_ID).getSingleResult();assertEquals(itemBidSummary.getName(), "AUCTION: New name");}tx.commit();em.close();} finally {TM.rollback();}}public Long storeItemAndBids() throws Exception {UserTransaction tx = TM.getUserTransaction();tx.begin();EntityManager em = JPA.createEntityManager();Item item = new Item();item.setName("Some item");item.setDescription("This is some description.");em.persist(item);for (int i = 1; i <= 3; i++) {Bid bid = new Bid();bid.setAmount(new BigDecimal(10 + i));bid.setItem(item);em.persist(bid);}tx.commit();em.close();return item.getId();}}

/examples/src/test/java/org/jpwh/test/advanced/AccessType.java
package org.jpwh.test.advanced;import org.jpwh.env.JPATest;
import org.jpwh.model.advanced.Item;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;import javax.persistence.EntityManager;
import javax.transaction.UserTransaction;import static org.testng.Assert.assertEquals;public class AccessType extends JPATest {@Overridepublic void configurePersistenceUnit() throws Exception {configurePersistenceUnit("AdvancedPU");}@Testpublic void storeLoadAccessType() throws Exception {UserTransaction tx = TM.getUserTransaction();try {tx.begin();EntityManager em = JPA.createEntityManager();Item someItem = new Item();someItem.setName("Some item");someItem.setDescription("This is some description.");em.persist(someItem);tx.commit();em.close();Long ITEM_ID = someItem.getId();tx.begin();em = JPA.createEntityManager();Item item = em.find(Item.class, ITEM_ID);assertEquals(item.getName(), "AUCTION: Some item");tx.commit();em.close();} finally {TM.rollback();}}}


/examples/src/test/java/org/jpwh/test/advanced/BooleanOverride.java

package org.jpwh.test.advanced;import org.jpwh.env.JPATest;
import org.jpwh.model.advanced.Item;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;import javax.persistence.EntityManager;
import javax.transaction.UserTransaction;import static org.testng.Assert.assertTrue;public class BooleanOverride extends JPATest {@BeforeClass@java.lang.Overridepublic void configurePersistenceUnit() throws Exception {configurePersistenceUnit("AdvancedPU");}@Testpublic void storeLoadOverride() throws Exception {UserTransaction tx = TM.getUserTransaction();try {tx.begin();EntityManager em = JPA.createEntityManager();Item someItem = new Item();someItem.setName("Some item");someItem.setDescription("This is some description.");someItem.setVerified(true);em.persist(someItem);tx.commit();em.close();Long ITEM_ID = someItem.getId();tx.begin();em = JPA.createEntityManager();Item item = em.find(Item.class, ITEM_ID);assertTrue(item.isVerified());tx.commit();em.close();} finally {TM.rollback();}}}


/examples/src/test/java/org/jpwh/test/advanced/DerivedProperties.java

package org.jpwh.test.advanced;import org.jpwh.env.JPATest;
import org.jpwh.model.advanced.Bid;
import org.jpwh.model.advanced.Item;
import org.testng.annotations.Test;import javax.persistence.EntityManager;
import javax.transaction.UserTransaction;
import java.math.BigDecimal;import static org.testng.Assert.assertEquals;//派生属性
public class DerivedProperties extends JPATest {@Overridepublic void configurePersistenceUnit() throws Exception {configurePersistenceUnit("AdvancedPU");}@Testpublic void storeLoadFormula() throws Exception {long ITEM_ID = storeItemAndBids();UserTransaction tx = TM.getUserTransaction();try {tx.begin();EntityManager em = JPA.createEntityManager();Item item = em.find(Item.class, ITEM_ID);assertEquals(item.getShortDescription(), "This is some...");tx.commit();em.close();} finally {TM.rollback();}}@Testpublic void storeLoadFormulaSubselect() throws Exception {long ITEM_ID = storeItemAndBids();UserTransaction tx = TM.getUserTransaction();try {tx.begin();EntityManager em = JPA.createEntityManager();Item item = em.find(Item.class, ITEM_ID);assertEquals(item.getAverageBidAmount().compareTo(new BigDecimal("12")), 0);tx.commit();em.close();} finally {TM.rollback();}}public Long storeItemAndBids() throws Exception {UserTransaction tx = TM.getUserTransaction();tx.begin();EntityManager em = JPA.createEntityManager();Item item = new Item();item.setName("Some item");item.setDescription("This is some description.");em.persist(item);for (int i = 1; i <= 3; i++) {Bid bid = new Bid();bid.setAmount(new BigDecimal(10 + i));bid.setItem(item);em.persist(bid);}tx.commit();em.close();return item.getId();}}

/examples/src/test/java/org/jpwh/test/advanced/GeneratedProperties.java

package org.jpwh.test.advanced;import org.hibernate.Session;
import org.hibernate.jdbc.Work;
import org.jpwh.env.DatabaseProduct;
import org.jpwh.env.JPATest;
import org.jpwh.model.advanced.Bid;
import org.jpwh.model.advanced.Item;
import org.testng.annotations.Test;import javax.persistence.EntityManager;
import javax.transaction.UserTransaction;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Date;import static org.testng.Assert.*;//生成的属性
public class GeneratedProperties extends JPATest {@Overridepublic void configurePersistenceUnit() throws Exception {configurePersistenceUnit("AdvancedPU");}@Overridepublic void afterJPABootstrap() throws Exception {if (!TM.databaseProduct.equals(DatabaseProduct.H2)) return;// LASTMODIFIED测试显示数据库触发器如何生成属性值,我们实际上需要一个触发器try (Session session = JPA.createEntityManager().unwrap(Session.class)) {session.doWork(new Work() {@Overridepublic void execute(Connection connection) throws SQLException {Statement stat = connection.createStatement();stat.execute("drop trigger if exists TRG_ITEM_LASTMODIFIED_INSERT");stat.execute("create trigger TRG_ITEM_LASTMODIFIED_INSERT after insert on ITEM" +" for each row call \"" + org.jpwh.shared.trigger.UpdateLastModifiedTrigger.class.getName() + "\"");stat.execute("drop trigger if exists TRG_ITEM_LASTMODIFIED_UPDATE");stat.execute("create trigger TRG_ITEM_LASTMODIFIED_UPDATE after update on ITEM" +" for each row call \"" + org.jpwh.shared.trigger.UpdateLastModifiedTrigger.class.getName() + "\"");stat.close();}});}}@Test(groups = {"H2"})public void storeLoadLastModified() throws Exception {long ITEM_ID = storeItemAndBids();UserTransaction tx = TM.getUserTransaction();try {tx.begin();EntityManager em = JPA.createEntityManager();Item item = em.find(Item.class, ITEM_ID);assertNotNull(item.getCreatedOn());Date lastModified = item.getLastModified();assertNotNull(lastModified);assertTrue(item.getCreatedOn().getTime() < lastModified.getTime());item.setDescription("Some modification.");em.flush();Date newLastModified = item.getLastModified();assertNotEquals(lastModified, newLastModified, "Modification time should have been updated");tx.commit();em.close();} finally {TM.rollback();}}@Testpublic void storeLoadInitialPrice() throws Exception {long ITEM_ID = storeItemAndBids();UserTransaction tx = TM.getUserTransaction();try {tx.begin();EntityManager em = JPA.createEntityManager();Item item = em.find(Item.class, ITEM_ID);tx.commit();em.close();assertEquals(item.getInitialPrice().compareTo(new BigDecimal("1")), 0);} finally {TM.rollback();}}public Long storeItemAndBids() throws Exception {UserTransaction tx = TM.getUserTransaction();tx.begin();EntityManager em = JPA.createEntityManager();Item item = new Item();item.setName("Some item");item.setDescription("This is some description.");em.persist(item);for (int i = 1; i <= 3; i++) {Bid bid = new Bid();bid.setAmount(new BigDecimal(10 + i));bid.setItem(item);em.persist(bid);}tx.commit();em.close();return item.getId();}}


/examples/src/test/java/org/jpwh/test/advanced/LazyProperties.java

package org.jpwh.test.advanced;import org.hibernate.Session;
import org.hibernate.engine.jdbc.StreamUtils;
import org.jpwh.env.JPATest;
import org.jpwh.model.advanced.Item;
import org.testng.annotations.Test;import javax.persistence.EntityManager;
import javax.transaction.UserTransaction;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.sql.Blob;
import java.util.Random;import static org.testng.Assert.assertEquals;public class LazyProperties extends JPATest {@Overridepublic void configurePersistenceUnit() throws Exception {configurePersistenceUnit("AdvancedPU");}@Testpublic void storeLoadProperties() throws Exception {UserTransaction tx = TM.getUserTransaction();try {tx.begin();EntityManager em = JPA.createEntityManager();Item someItem = new Item();someItem.setName("Some item");someItem.setDescription("This is some description.");byte[] bytes = new byte[131072];new Random().nextBytes(bytes);someItem.setImage(bytes);em.persist(someItem);tx.commit();em.close();Long ITEM_ID = someItem.getId();tx.begin();em = JPA.createEntityManager();Item item = em.find(Item.class, ITEM_ID);// Accessing one initializes ALL lazy properties in a single SELECTassertEquals(item.getDescription(), "This is some description.");assertEquals(item.getImage().length, 131072); // 128 kilobytestx.commit();em.close();} finally {TM.rollback();}}@Testpublic void storeLoadLocator() throws Exception {// TODO: This test fails on H2 standalone// http://groups.google.com/group/h2-database/browse_thread/thread/9c6f4893a62c9b1aUserTransaction tx = TM.getUserTransaction();try {tx.begin();EntityManager em = JPA.createEntityManager();byte[] bytes = new byte[131072];new Random().nextBytes(bytes);InputStream imageInputStream = new ByteArrayInputStream(bytes);int byteLength = bytes.length;Item someItem = new Item();someItem.setName("Some item");someItem.setDescription("This is some description.");// Need the native Hibernate APISession session = em.unwrap(Session.class);// You need to know the number of bytes you want to read from the stream!Blob blob = session.getLobHelper().createBlob(imageInputStream, byteLength);someItem.setImageBlob(blob);em.persist(someItem);tx.commit();em.close();Long ITEM_ID = someItem.getId();tx.begin();em = JPA.createEntityManager();Item item = em.find(Item.class, ITEM_ID);// You can stream the bytes directly...InputStream imageDataStream = item.getImageBlob().getBinaryStream();// ... or materialize them into memory:ByteArrayOutputStream outStream = new ByteArrayOutputStream();StreamUtils.copy(imageDataStream, outStream);byte[] imageBytes = outStream.toByteArray();assertEquals(imageBytes.length, 131072);tx.commit();em.close();} finally {TM.rollback();}}}

/examples/src/test/java/org/jpwh/test/advanced/NestedComponents.java

package org.jpwh.test.advanced;import org.jpwh.env.JPATest;
import org.jpwh.model.advanced.Address;
import org.jpwh.model.advanced.City;
import org.jpwh.model.advanced.User;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;import javax.persistence.EntityManager;
import javax.transaction.UserTransaction;
import java.util.Locale;import static org.testng.Assert.assertEquals;//嵌套组件
public class NestedComponents extends JPATest {@Overridepublic void configurePersistenceUnit() throws Exception {configurePersistenceUnit("AdvancedPU");}@Testpublic void storeAndLoadUsers() throws Exception {UserTransaction tx = TM.getUserTransaction();try {tx.begin();EntityManager em = JPA.createEntityManager();City city = new City();city.setZipcode("12345");city.setName("Some City");city.setCountry(Locale.GERMANY.getCountry());Address address = new Address();address.setStreet("Some Street 123");address.setCity(city);User userOne = new User();userOne.setAddress(address);em.persist(userOne);tx.commit();em.close();tx.begin();em = JPA.createEntityManager();User u = em.find(User.class, userOne.getId());assertEquals(u.getAddress().getStreet(), "Some Street 123");assertEquals(u.getAddress().getCity().getZipcode(), "12345");assertEquals(u.getAddress().getCity().getCountry(), Locale.GERMANY.getCountry());tx.commit();em.close();} finally {TM.rollback();}}}

/examples/src/test/java/org/jpwh/test/advanced/Temporal.java

package org.jpwh.test.advanced;import org.jpwh.env.JPATest;
import org.jpwh.model.advanced.Item;
import org.testng.annotations.Test;import javax.persistence.EntityManager;
import javax.transaction.UserTransaction;import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;import static org.testng.Assert.*;//临时的
public class Temporal extends JPATest {@Overridepublic void configurePersistenceUnit() throws Exception {configurePersistenceUnit("AdvancedPU");}@Testpublic void storeLoadTemporal() throws Exception {UserTransaction tx = TM.getUserTransaction();try {tx.begin();EntityManager em = JPA.createEntityManager();Item someItem = new Item();someItem.setName("Some item");someItem.setDescription("This is some description.");// someItem.setReviewedOn(Instant.now().plusSeconds(60)); // A future timeem.persist(someItem);tx.commit();em.close();Long ITEM_ID = someItem.getId();Date ORIGINAL_CREATION_DATE = someItem.getCreatedOn();tx.begin();em = JPA.createEntityManager();Item item = em.find(Item.class, ITEM_ID);// java.util.Date and java.sql.Timestamp are not symmetric!assertFalse(item.getCreatedOn().equals(ORIGINAL_CREATION_DATE));assertFalse(item.getCreatedOn().getClass().equals(ORIGINAL_CREATION_DATE.getClass()));// 这是如何正确比较Java中的时间值...assertEquals(ORIGINAL_CREATION_DATE.getTime(), item.getCreatedOn().getTime());// 或者使用稍微令人讨厌但相当可怕的日历APICalendar oldDate = new GregorianCalendar();oldDate.setTime(ORIGINAL_CREATION_DATE);Calendar newDate = new GregorianCalendar();newDate.setTime(item.getCreatedOn());assertEquals(oldDate, newDate);// Or the Java 8 API// assertTrue(item.getReviewedOn().isAfter(item.getCreatedOn().toInstant()));tx.commit();em.close();} finally {TM.rollback();}}}

/examples/src/test/java/org/jpwh/test/advanced/TransformingColumns.java

package org.jpwh.test.advanced;import org.hibernate.Session;
import org.hibernate.jdbc.Work;
import org.jpwh.env.JPATest;
import org.jpwh.model.advanced.Bid;
import org.jpwh.model.advanced.Item;
import org.testng.annotations.Test;import javax.persistence.EntityManager;
import javax.transaction.UserTransaction;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;//转换列
public class TransformingColumns extends JPATest {@Overridepublic void configurePersistenceUnit() throws Exception {configurePersistenceUnit("AdvancedPU");}@Testpublic void storeLoadTransform() throws Exception {final long ITEM_ID = storeItemAndBids();UserTransaction tx = TM.getUserTransaction();try {tx.begin();EntityManager em = JPA.createEntityManager();{Item item = em.find(Item.class, ITEM_ID);assertEquals(item.getMetricWeight(), 2.0);final boolean[] tests = new boolean[1];em.unwrap(Session.class).doWork(new Work() {@Overridepublic void execute(Connection connection) throws SQLException {PreparedStatement statement = null;ResultSet result = null;try {statement = connection.prepareStatement("select IMPERIALWEIGHT from ITEM where ID = ?");statement.setLong(1, ITEM_ID);result = statement.executeQuery();while (result.next()) {Double imperialWeight = result.getDouble("IMPERIALWEIGHT");assertEquals(imperialWeight, 4.40924);tests[0] = true;}} finally {if (result != null)result.close();if (statement != null)statement.close();}}});assertTrue(tests[0]);}em.clear();{List<Item> result =em.createQuery("select i from Item i where i.metricWeight = :w").setParameter("w", 2.0).getResultList();assertEquals(result.size(), 1);}em.clear();tx.commit();em.close();} finally {TM.rollback();}}public Long storeItemAndBids() throws Exception {UserTransaction tx = TM.getUserTransaction();tx.begin();EntityManager em = JPA.createEntityManager();Item item = new Item();item.setName("Some item");item.setMetricWeight(2);item.setDescription("This is some description.");em.persist(item);for (int i = 1; i <= 3; i++) {Bid bid = new Bid();bid.setAmount(new BigDecimal(10 + i));bid.setItem(item);em.persist(bid);}tx.commit();em.close();return item.getId();}}


这篇关于Hibernate实战(第二版)笔记----第四章--映射持久化类的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1068631

相关文章

Java枚举类实现Key-Value映射的多种实现方式

《Java枚举类实现Key-Value映射的多种实现方式》在Java开发中,枚举(Enum)是一种特殊的类,本文将详细介绍Java枚举类实现key-value映射的多种方式,有需要的小伙伴可以根据需要... 目录前言一、基础实现方式1.1 为枚举添加属性和构造方法二、http://www.cppcns.co

Spring Boot + MyBatis Plus 高效开发实战从入门到进阶优化(推荐)

《SpringBoot+MyBatisPlus高效开发实战从入门到进阶优化(推荐)》本文将详细介绍SpringBoot+MyBatisPlus的完整开发流程,并深入剖析分页查询、批量操作、动... 目录Spring Boot + MyBATis Plus 高效开发实战:从入门到进阶优化1. MyBatis

MyBatis 动态 SQL 优化之标签的实战与技巧(常见用法)

《MyBatis动态SQL优化之标签的实战与技巧(常见用法)》本文通过详细的示例和实际应用场景,介绍了如何有效利用这些标签来优化MyBatis配置,提升开发效率,确保SQL的高效执行和安全性,感... 目录动态SQL详解一、动态SQL的核心概念1.1 什么是动态SQL?1.2 动态SQL的优点1.3 动态S

Pandas使用SQLite3实战

《Pandas使用SQLite3实战》本文主要介绍了Pandas使用SQLite3实战,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学... 目录1 环境准备2 从 SQLite3VlfrWQzgt 读取数据到 DataFrame基础用法:读

SpringCloud之consul服务注册与发现、配置管理、配置持久化方式

《SpringCloud之consul服务注册与发现、配置管理、配置持久化方式》:本文主要介绍SpringCloud之consul服务注册与发现、配置管理、配置持久化方式,具有很好的参考价值,希望... 目录前言一、consul是什么?二、安装运行consul三、使用1、服务发现2、配置管理四、数据持久化总

Python实战之屏幕录制功能的实现

《Python实战之屏幕录制功能的实现》屏幕录制,即屏幕捕获,是指将计算机屏幕上的活动记录下来,生成视频文件,本文主要为大家介绍了如何使用Python实现这一功能,希望对大家有所帮助... 目录屏幕录制原理图像捕获音频捕获编码压缩输出保存完整的屏幕录制工具高级功能实时预览增加水印多平台支持屏幕录制原理屏幕

最新Spring Security实战教程之Spring Security安全框架指南

《最新SpringSecurity实战教程之SpringSecurity安全框架指南》SpringSecurity是Spring生态系统中的核心组件,提供认证、授权和防护机制,以保护应用免受各种安... 目录前言什么是Spring Security?同类框架对比Spring Security典型应用场景传统

最新Spring Security实战教程之表单登录定制到处理逻辑的深度改造(最新推荐)

《最新SpringSecurity实战教程之表单登录定制到处理逻辑的深度改造(最新推荐)》本章节介绍了如何通过SpringSecurity实现从配置自定义登录页面、表单登录处理逻辑的配置,并简单模拟... 目录前言改造准备开始登录页改造自定义用户名密码登陆成功失败跳转问题自定义登出前后端分离适配方案结语前言

OpenManus本地部署实战亲测有效完全免费(最新推荐)

《OpenManus本地部署实战亲测有效完全免费(最新推荐)》文章介绍了如何在本地部署OpenManus大语言模型,包括环境搭建、LLM编程接口配置和测试步骤,本文给大家讲解的非常详细,感兴趣的朋友一... 目录1.概况2.环境搭建2.1安装miniconda或者anaconda2.2 LLM编程接口配置2

基于Canvas的Html5多时区动态时钟实战代码

《基于Canvas的Html5多时区动态时钟实战代码》:本文主要介绍了如何使用Canvas在HTML5上实现一个多时区动态时钟的web展示,通过Canvas的API,可以绘制出6个不同城市的时钟,并且这些时钟可以动态转动,每个时钟上都会标注出对应的24小时制时间,详细内容请阅读本文,希望能对你有所帮助...