@

Sqlite配置

应用程序里使用Sqlite作为数据库,使用EntityFramworkCore作为ORM,使用CodeFirst方式用EFCore初始化Sqlite数据库文件:mato.db

在MatoProductivity.Core项目的appsettings.json中添加本地sqlite连接字符串

  "ConnectionStrings": {
"Default": "Data Source=file:{0};"
},
...

这里文件是一个占位符,通过代码hardcode到配置文件

在MatoProductivityCoreModule.cs中,重写PreInitialize并设置Configuration.DefaultNameOrConnectionString:

public override void PreInitialize()
{
LocalizationConfigurer.Configure(Configuration.Localization); Configuration.Settings.Providers.Add<CommonSettingProvider>(); string documentsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), MatoProductivityConsts.LocalizationSourceName); var configuration = AppConfigurations.Get(documentsPath, development);
var connectionString = configuration.GetConnectionString(MatoProductivityConsts.ConnectionStringName); var dbName = "mato.db";
string dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), MatoProductivityConsts.LocalizationSourceName, dbName); Configuration.DefaultNameOrConnectionString = String.Format(connectionString, dbPath);
base.PreInitialize();
}

创建实体

接下来定义实体类

笔记实体类

笔记用于存储实体,在笔记列表中,每个笔记都有标题和内容,创建时间等内容。

定义于\MatoProductivity.Core\Models\Entities\Note.cs


public class Note : FullAuditedEntity<long>
{
public Note()
{ }
public Note(string name, bool isHidden, bool isRemovable)
{
Title = name;
IsHidden = isHidden;
IsRemovable = isRemovable;
} [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public override long Id { get; set; } public ICollection<NoteSegment> NoteSegments { get; set; } public string Title { get; set; }
public string Type { get; set; }
public string Status { get; set; }
public string Desc { get; set; }
public string Icon { get; set; }
public string Color { get; set; }
public string BackgroundColor { get; set; }
public string BackgroundImage { get; set; } public string PreViewContent { get; set; } public bool IsEditable { get; set; } public bool IsHidden { get; set; } public bool IsRemovable { get; set; }
public bool CanSimplified { get; set; } }

笔记分组实体

定义于\MatoProductivity.Core\Models\Entities\NoteGroup.cs

public class NoteGroup : FullAuditedEntity<long>
{
public NoteGroup()
{ }
public NoteGroup(string name, bool isHidden, bool isRemovable)
{
Title = name;
IsHidden = isHidden;
IsRemovable = isRemovable;
} [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public override long Id { get; set; }
public string Title { get; set; } public bool IsHidden { get; set; } public bool IsRemovable { get; set; } public ICollection<Note> Notes { get; set; }
}

笔记片段实体

定义于\MatoProductivity.Core\Models\Entities\NoteSegment.cs

public class NoteSegment : FullAuditedEntity<long>, INoteSegment
{
public NoteSegment()
{ } [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public override long Id { get; set; } [ForeignKey(nameof(NoteId))]
public Note Note { get; set; } public ICollection<NoteSegmentPayload> NoteSegmentPayloads { get; set; } public long NoteId { get; set; } public string Title { get; set; }
public string Type { get; set; }
public string Status { get; set; }
public string Desc { get; set; }
public string Icon { get; set; }
public string Color { get; set; }
public int Rank { get; set; } public bool IsHidden { get; set; } public bool IsRemovable { get; set; } public INoteSegmentPayload GetNoteSegmentPayload(string key)
{
if (NoteSegmentPayloads != null)
{
return NoteSegmentPayloads.FirstOrDefault(c => c.Key == key);
}
return default;
} public void SetNoteSegmentPayload(INoteSegmentPayload noteSegmentPayload)
{
if (NoteSegmentPayloads != null)
{
var currentPayload = NoteSegmentPayloads.FirstOrDefault(c => c.Key == noteSegmentPayload.Key);
if (currentPayload != null)
{
NoteSegmentPayloads.Remove(currentPayload);
}
if (!this.IsTransient())
{
(noteSegmentPayload as NoteSegmentPayload).NoteSegmentId = this.Id;
}
NoteSegmentPayloads.Add((noteSegmentPayload as NoteSegmentPayload));
}
} public INoteSegmentPayload GetOrSetNoteSegmentPayload(string key, INoteSegmentPayload noteSegmentPayload)
{
if (NoteSegmentPayloads != null)
{
var currentPayload = NoteSegmentPayloads.FirstOrDefault(c => c.Key == key);
if (currentPayload != null)
{
return currentPayload;
}
if (noteSegmentPayload != null)
{
if (!this.IsTransient())
{
(noteSegmentPayload as NoteSegmentPayload).NoteSegmentId = this.Id;
}
NoteSegmentPayloads.Add((noteSegmentPayload as NoteSegmentPayload));
}
return noteSegmentPayload;
}
return noteSegmentPayload;
} }

笔记片段负载实体

笔记片段负载与笔记片段实体为一对多的关系,用于存储笔记片段的详细内容。

定义于\MatoProductivity.Core\Models\Entities\NoteSegmentPayload.cs

public class NoteSegmentPayload : FullAuditedEntity<long>, INoteSegmentPayload
{
public NoteSegmentPayload()
{ } public NoteSegmentPayload(string key, object value, string valuetype = null)
{
if (value is string)
{
this.SetStringValue((value as string).ToString());
}
else if (value is byte[])
{
this.Value = value as byte[];
}
else if (value is DateTime)
{
this.SetStringValue(((DateTime)value).ToString("yyyy-MM-dd HH:mm:ss"));
}
else
{
this.SetStringValue(value.ToString());
}
this.Key = key;
this.ValueType = valuetype; } [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public override long Id { get; set; } [ForeignKey(nameof(NoteSegmentId))]
public NoteSegment NoteSegment { get; set; } public long NoteSegmentId { get; set; } public string Key { get; set; } public byte[] Value { get; set; } public string ValueType { get; set; } [NotMapped]
public string StringValue => GetStringValue(); public T GetConcreteValue<T>() where T : struct
{
var value = Encoding.UTF8.GetString(Value);
T result = value.To<T>();
return result;
} public string GetStringValue()
{
var value = Encoding.UTF8.GetString(Value);
return value;
} public void SetStringValue(string value)
{
this.Value = Encoding.UTF8.GetBytes(value);
}
}

笔记片段仓库实体

用于在编辑笔记页面的添加片段菜单中,加载所有可用的片段

定义于\MatoProductivity.Core\Models\Entities\NoteSegmentStore.cs

public class NoteSegmentStore : Entity<long>
{ [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public override long Id { get; set; }
public string Title { get; set; }
public string Type { get; set; }
public string Category { get; set; }
public string Status { get; set; }
public string Desc { get; set; }
public string Icon { get; set; }
public string Color { get; set; }
public bool IsHidden { get; set; } public bool IsRemovable { get; set; } }

笔记模板(场景)实体

定义于\MatoProductivity.Core\Models\Entities\NoteTemplate.cs

public class NoteTemplate : FullAuditedEntity<long>
{
public NoteTemplate()
{ }
public NoteTemplate(string name, bool isHidden, bool isRemovable)
{
Title = name;
IsHidden = isHidden;
IsRemovable = isRemovable;
} [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public override long Id { get; set; } public ICollection<NoteSegmentTemplate> NoteSegmentTemplates { get; set; } public string Title { get; set; }
public string Type { get; set; }
public string Status { get; set; }
public string Desc { get; set; }
public string Icon { get; set; }
public string Color { get; set; }
public string BackgroundColor { get; set; }
public string BackgroundImage { get; set; } public string PreViewContent { get; set; } public bool IsEditable { get; set; } public bool IsHidden { get; set; } public bool IsRemovable { get; set; } public bool CanSimplified { get; set; } }

笔记片段模板实体

定义于\MatoProductivity.Core\Models\Entities\NoteSegmentTemplate.cs

public class NoteSegmentTemplate : FullAuditedEntity<long>, INoteSegment
{
public NoteSegmentTemplate()
{ } [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public override long Id { get; set; } [ForeignKey(nameof(NoteTemplateId))]
public NoteTemplate NoteTemplate { get; set; } public ICollection<NoteSegmentTemplatePayload> NoteSegmentTemplatePayloads { get; set; } public long NoteTemplateId { get; set; } public string Title { get; set; }
public string Type { get; set; }
public string Status { get; set; }
public string Desc { get; set; }
public string Icon { get; set; }
public string Color { get; set; }
public int Rank { get; set; } public bool IsHidden { get; set; } public bool IsRemovable { get; set; } public INoteSegmentPayload GetNoteSegmentPayload(string key)
{
if (NoteSegmentTemplatePayloads != null)
{
return NoteSegmentTemplatePayloads.FirstOrDefault(c => c.Key == key);
}
return default;
} public void SetNoteSegmentPayload(INoteSegmentPayload noteSegmentPayload)
{
if (NoteSegmentTemplatePayloads != null)
{
var currentPayload = NoteSegmentTemplatePayloads.FirstOrDefault(c => c.Key == noteSegmentPayload.Key);
if (currentPayload != null)
{
NoteSegmentTemplatePayloads.Remove(currentPayload);
}
if (!this.IsTransient())
{
(noteSegmentPayload as NoteSegmentTemplatePayload).NoteSegmentTemplateId = this.Id;
}
NoteSegmentTemplatePayloads.Add((noteSegmentPayload as NoteSegmentTemplatePayload));
}
} public INoteSegmentPayload GetOrSetNoteSegmentPayload(string key, INoteSegmentPayload noteSegmentPayload)
{
if (NoteSegmentTemplatePayloads != null)
{
var currentPayload = NoteSegmentTemplatePayloads.FirstOrDefault(c => c.Key == key);
if (currentPayload != null)
{
return currentPayload;
}
if (noteSegmentPayload != null)
{
if (!this.IsTransient())
{
(noteSegmentPayload as NoteSegmentTemplatePayload).NoteSegmentTemplateId = this.Id;
}
NoteSegmentTemplatePayloads.Add((noteSegmentPayload as NoteSegmentTemplatePayload));
}
return noteSegmentPayload;
}
return noteSegmentPayload;
} }

笔记片段模板负载实体

定义于\MatoProductivity.Core\Models\Entities\NoteSegmentTemplatePayload.cs

public class NoteSegmentTemplatePayload : FullAuditedEntity<long>, INoteSegmentPayload
{
public NoteSegmentTemplatePayload()
{ } public NoteSegmentTemplatePayload(string key, object value, string valuetype = null)
{
if (value is string)
{
this.SetStringValue((value as string).ToString());
}
else if (value is byte[])
{
this.Value = value as byte[];
}
else if (value is DateTime)
{
this.SetStringValue(((DateTime)value).ToString("yyyy-MM-dd HH:mm:ss"));
}
else
{
this.SetStringValue(value.ToString());
}
this.Key = key;
this.ValueType = valuetype; } [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public override long Id { get; set; } [ForeignKey(nameof(NoteSegmentTemplateId))]
public NoteSegmentTemplate NoteSegmentTemplate { get; set; } public long NoteSegmentTemplateId { get; set; } public string Key { get; set; } public byte[] Value { get; set; } public string ValueType { get; set; } [NotMapped]
public string StringValue => GetStringValue(); public T GetConcreteValue<T>() where T : struct
{
var value = Encoding.UTF8.GetString(Value);
T result = value.To<T>();
return result;
} public string GetStringValue()
{
var value = Encoding.UTF8.GetString(Value);
return value;
} public void SetStringValue(string value)
{
this.Value = Encoding.UTF8.GetBytes(value);
}
}

配置EF

数据库上下文对象MatoProductivityDbContext定义如下

    public class MatoProductivityDbContext : AbpDbContext
{
//Add DbSet properties for your entities... public DbSet<Note> Note { get; set; }
public DbSet<NoteGroup> NoteGroup { get; set; }
public DbSet<NoteSegment> NoteSegment { get; set; }
public DbSet<NoteSegmentStore> NoteSegmentStore { get; set; }
public DbSet<NoteSegmentPayload> NoteSegmentPayload { get; set; }
public DbSet<NoteTemplate> NoteTemplate { get; set; }
public DbSet<NoteSegmentTemplate> NoteSegmentTemplate { get; set; }
public DbSet<NoteSegmentTemplatePayload> NoteSegmentTemplatePayload { get; set; }
public DbSet<Theme> Theme { get; set; }
public DbSet<Setting> Setting { get; set; }
public MatoProductivityDbContext(DbContextOptions<MatoProductivityDbContext> options)
: base(options)
{ }
}

MatoProductivity.EntityFrameworkCore是应用程序数据库的维护和管理项目,依赖于Abp.EntityFrameworkCore。

在MatoProductivity.EntityFrameworkCore项目中csproj文件中,引用下列包

<PackageReference Include="Abp.EntityFrameworkCore" Version="7.4.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.0">

在该项目MatoProductivityEntityFrameworkCoreModule.cs 中,将注册上下文对象,并在程序初始化运行迁移,此时将在设备上生成mato.db文件

public override void PostInitialize()
{
Helper.WithDbContextHelper.WithDbContext<MatoProductivityDbContext>(IocManager, RunMigrate);
if (!SkipDbSeed)
{
SeedHelper.SeedHostDb(IocManager);
}
} public static void RunMigrate(MatoProductivityDbContext dbContext)
{
dbContext.Database.Migrate();
}

创建映射

从场景到笔记,或者说从模板到实例,我们需要映射,例如从笔记片段菜单中选择一个片段添加,那么需要从笔记片段仓库实体(NoteSegmentStore)映射到笔记片段实体(NoteSegment)或者,在编辑场景中,映射到笔记片段模板实体(NoteSegmentTemplate)。

[AutoMapTo(typeof(NoteSegment), typeof(NoteSegmentTemplate))]

public class NoteSegmentStore : Entity<long>
{
...
}

使用时:

var note = ObjectMapper.Map<NoteSegment>(noteSegmentStore);

ABP框架默认使用AutoMapper进行映射,所以需要配置映射关系。

Configuration.Modules.AbpAutoMapper().Configurators.Add(config =>
{
IgnoreAbpProperties(config.CreateMap<NoteTemplate, Note>()
.ForMember(
c => c.NoteSegments,
options => options.MapFrom(input => input.NoteSegmentTemplates))
.ForMember(
c => c.Id,
options => options.Ignore())); IgnoreAbpProperties(config.CreateMap<Note, NoteTemplate>()
.ForMember(
c => c.NoteSegmentTemplates,
options => options.MapFrom(input => input.NoteSegments))
.ForMember(
c => c.Id,
options => options.Ignore())); IgnoreAbpProperties(config.CreateMap<NoteSegmentTemplate, NoteSegment>()
.ForMember(
c => c.Note,
options => options.MapFrom(input => input.NoteTemplate))
.ForMember(
c => c.NoteSegmentPayloads,
options => options.MapFrom(input => input.NoteSegmentTemplatePayloads))
.ForMember(
c => c.NoteId,
options => options.Ignore())
.ForMember(
c => c.Id,
options => options.Ignore())); IgnoreAbpProperties(config.CreateMap<NoteSegmentStore, NoteSegment>()
.ForMember(
c => c.Id,
options => options.Ignore())); IgnoreAbpProperties(config.CreateMap<NoteSegment, NoteSegmentTemplate>()
.ForMember(
c => c.NoteTemplate,
options => options.MapFrom(input => input.Note))
.ForMember(
c => c.NoteTemplateId,
options => options.Ignore())
.ForMember(
c => c.NoteSegmentTemplatePayloads,
options => options.MapFrom(input => input.NoteSegmentPayloads))
.ForMember(
c => c.Id,
options => options.Ignore())); IgnoreAbpProperties(config.CreateMap<NoteSegmentTemplatePayload, NoteSegmentPayload>()
.ForMember(
c => c.NoteSegment,
options => options.MapFrom(input => input.NoteSegmentTemplate))
.ForMember(
c => c.NoteSegmentId,
options => options.Ignore()) .ForMember(
c => c.Id,
options => options.Ignore())); IgnoreAbpProperties(
config.CreateMap<NoteSegmentPayload, NoteSegmentTemplatePayload>()
.ForMember(
c => c.NoteSegmentTemplate,
options => options.MapFrom(input => input.NoteSegment))
.ForMember(
c => c.NoteSegmentTemplateId,
options => options.Ignore())); });

迁移和种子数据

MatoProductivity.EntityFrameworkCore.Seed.SeedHelper可在程序启动时,访问数据库,并初始化种子数据。

public override void PostInitialize()
{
Helper.WithDbContextHelper.WithDbContext<MatoProductivityDbContext>(IocManager, RunMigrate);
if (!SkipDbSeed)
{
SeedHelper.SeedHostDb(IocManager);
}
}

它通过SkipDbSeed来决定是否跳过执行种子数据初始化。我们需要在安装完成App后第一次运行才执行种子数据初始化。

MAUI中提供了VersionTracking.Default.IsFirstLaunchEver方式获取是否是第一次在此设备上启动应用,请查看官方文档

public override async void Initialize()
{
IocManager.RegisterAssemblyByConvention(typeof(MatoProductivityModule).GetAssembly());
if (VersionTracking.Default.IsFirstLaunchEver)
{
MatoProductivityEntityFrameworkCoreModule.SkipDbSeed = false;
}
else
{
MatoProductivityEntityFrameworkCoreModule.SkipDbSeed = true; }
}

在InitialDbBuilder中我们定义了大多数的业务初始数据,具体的实现方式请查阅源码。

internal void Create()
{ CreateSetting("Theme", "Light");
CreateSetting("DetailPageMode", "PreviewPage"); CreateNoteSegmentStore("时间戳", "时间/提醒", "DateTimeSegment", "记录一个瞬时时间", FaIcons.IconClockO, "#D8292B");
CreateNoteSegmentStore("计时器", "时间/提醒", "TimerSegment", "创建一个计时器,当它结束时会通知您", FaIcons.IconBell, "#D8292B");
CreateNoteSegmentStore("笔记", "文本", "TextSegment", "随时用文本记录您的想法", FaIcons.IconStickyNoteO, "#E1A08B");
CreateNoteSegmentStore("Todo", "文本", "TodoSegment", "记录一个Todo项目", FaIcons.IconCheckSquareO, "#E1A08B");
CreateNoteSegmentStore("数值", "文本", "KeyValueSegment", "记录数值,以便统计数据", FaIcons.IconLineChart, "#E1A08B");
CreateNoteSegmentStore("手绘", "文件", "ScriptSegment", "创建一个手绘", FaIcons.IconPaintBrush, "#AD9CC2");
CreateNoteSegmentStore("照片/视频", "文件", "MediaSegment", "拍照或摄像", FaIcons.IconCamera, "#AD9CC2");
CreateNoteSegmentStore("文档", "文件", "DocumentSegment", "从您设备中选取一个文档", FaIcons.IconFile, "#AD9CC2");
CreateNoteSegmentStore("录音", "文件", "VoiceSegment", "记录一段声音", FaIcons.IconMicrophone, "#AD9CC2");
CreateNoteSegmentStore("地点", "其它", "LocationSegment", "获取当前地点,或者从地图上选取一个地点", FaIcons.IconMapMarker, "#6D987C");
CreateNoteSegmentStore("天气", "其它", "WeatherSegment", "获取当前天气信息", FaIcons.IconCloud, "#6D987C");
CreateNoteSegmentStore("联系人", "其它", "ContactSegment", "从您设备的通讯录中选择一个联系人", FaIcons.IconUser, "#6D987C");
}

项目地址

GitHub:MatoProductivity

[MAUI 项目实战] 笔记App(二):数据库设计的更多相关文章

  1. Spring Boot +Vue 项目实战笔记(二):前后端结合测试(登录页面开发)

    前言:关于开发环境 每位 Coder 都有自己偏好的开发工具,从大的方面划分主要有文本编辑器流和 IDE 流两种,我有一段时间也喜欢用编辑器(Sublime Text.Vim),但对我来说开发效率确实 ...

  2. 【慕课网实战】Spark Streaming实时流处理项目实战笔记十二之铭文升级版

    铭文一级: ======Pull方式整合 Flume Agent的编写: flume_pull_streaming.conf simple-agent.sources = netcat-sources ...

  3. Unity3D项目实战笔记(5):延时功能的几种实现

    我所做过的系统,分单机版系统(2005年).CS系统(2010年).实时系统(2015年),各个系统均有“延时”功能:定时调度的: 本博客说的是实时系统中的延时功能(基于Unity3D游戏引擎). 在 ...

  4. [MAUI 项目实战] 手势控制音乐播放器(一): 概述与架构

    这是一篇系列博文.请关注我,学习更多.NET MAUI开发知识! [MAUI 项目实战] 手势控制音乐播放器(一): 概述与架构 [MAUI 项目实战] 手势控制音乐播放器(二): 手势交互 [MAU ...

  5. Unity3D项目实战笔记(10):Unity3D编译IPA的PostEvents–节约时间利器

    最近,SDK支付等接入差不多了,就从Unity3D生成IPA (企业版License), 然,需要手动执行的PostEvents竟然多大10项+, 这些我默默的承受了1周时间,每次约浪费20分钟-额外 ...

  6. 【慕课网实战】Spark Streaming实时流处理项目实战笔记二十一之铭文升级版

    铭文一级: DataV功能说明1)点击量分省排名/运营商访问占比 Spark SQL项目实战课程: 通过IP就能解析到省份.城市.运营商 2)浏览器访问占比/操作系统占比 Hadoop项目:userA ...

  7. 【慕课网实战】Spark Streaming实时流处理项目实战笔记二之铭文升级版

    铭文一级: 第二章:初识实时流处理 需求:统计主站每个(指定)课程访问的客户端.地域信息分布 地域:ip转换 Spark SQL项目实战 客户端:useragent获取 Hadoop基础课程 ==&g ...

  8. 项目实战11—企业级nosql数据库应用与实战-redis的主从和集群

    企业级nosql数据库应用与实战-redis 环境背景:随着互联网2.0时代的发展,越来越多的公司更加注重用户体验和互动,这些公司的平台上会出现越来越多方便用户操作和选择的新功能,如优惠券发放.抢红包 ...

  9. JavaWeb项目学习教程(2) 系统数据库设计

    最开始本来想写一个管理系统,因为考虑到期末来临,我女朋友就可以看着教程然后学一些东西,然后可以自己慢慢手敲代码.但无奈自己也太懒,两个月过后,我才开始继续写这个博客,而现在我都已经开学了.不过博客还是 ...

  10. 【慕课网实战】Spark Streaming实时流处理项目实战笔记十五之铭文升级版

    铭文一级:[木有笔记] 铭文二级: 第12章 Spark Streaming项目实战 行为日志分析: 1.访问量的统计 2.网站黏性 3.推荐 Python实时产生数据 访问URL->IP信息- ...

随机推荐

  1. Java中双括号初始化是个什么操作

    最近在阅读Mybatis源码的时候,看到了一种原来很少见到的语法: public class RichType { ... private List richList = new ArrayList( ...

  2. 领域驱动设计(Domain-Driven Design,简称DDD)【简介 个人学习笔记】

    找到了第 1 篇资料:领域驱动设计详解:是什么.为什么.怎么做? - 知乎 找到了第 2 篇资料:领域驱动架构(DDD)建模中的模型到底是什么? - 知乎 找到了第 3 篇资料:一文看懂DDD 领域驱 ...

  3. 直播相关-搭建直播流服务器nodejs

    一.安装nodejs环境 去nodejs官方网站下载安装包 https://nodejs.org/en/#download 安装完成之后测试: LUNLI-MC1:~ lunli$ node -v v ...

  4. 电脑网卡把报文的vlan tag去掉

    1 现象 现象说明:从电脑的网卡(用的Realtek)进来一个带vlan tag的报文,但是使用wireshark抓取的报文没有vlan tag. 解决方式如下:需要注册表. 参考链接1:https: ...

  5. 操作标签的属性和属性值 table表格

     // 操作标签的属性和属性值         // 特殊的属性           // 可以直接通过 点语法或者[]语法来操作的属性         // id 和 class           ...

  6. LeetCode 409. Longest Palindrome 最长回文串(C++/Java)

    题目: Given a string which consists of lowercase or uppercase letters, find the length of the longest ...

  7. 关于 ulimit 的两个天坑

    稍微有点 Linux 经验的人一定会遇到过 "Too many open files" 错误,这个错误本质是 ulimit 设置不合理导致的.关于 ulimit 设置,有哪些需要注 ...

  8. springboot增加@EnableAsync注解,否则方法中的@Async注解没有生效

    springboot增加@EnableAsync注解,否则方法中的@Async注解没有生效. @EnableFeignClients(basePackages = {"com.test&qu ...

  9. post请求 restTemplate.postForObject restTemplate.postForEntity java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to xxx POSTpost请求

    1.restTemplate调用的两种方式及获取字符串转换对象model的处理,统一按接收字符串,然后gson转换为对象的方式. ResponseData对象包含的属性private String r ...

  10. 轻松实现H5页面下拉刷新:滑动触发、高度提示与数据刷新全攻略

    前段时间在做小程序到H5的迁移,其中小程序中下拉刷新的功能引起了产品的注意.他说到,哎,我们迁移后的H5页面怎么没有下拉刷新,于是乎,我就急忙将这部分的内容给填上. 本来是计划使用成熟的组件库来实现, ...