首页 文章 精选 留言 我的

精选列表

搜索[链源罗盘],共10000篇文章
优秀的个人博客,低调大师

等个有“源”人|OpenHarmony 成长计划学生挑战赛报名启动

OpenAtom OpenHarmony(以下简称“OpenHarmony)开源开发者成长计划—解决方案学生挑战赛(以下简称“本大赛”或“成长计划学生挑战赛”)的使命是使用OpenHarmony技术解决联合国 17 项可持续发展的目标中一个或多个挑战,鼓励学生开发者积极参与开源软件的开发与创新,帮助开发者在开源项目中成长。 什么是“联合国17项可持续发展目标”? 17项目标提出了我们面临的全球挑战,涵盖贫困、不平等、气候、环境退化、繁荣以及和平与正义等方面。 本大赛面向所有在校大学生,注册、认证即可报名参与成长计划学生挑战赛,若组团参赛则人数不得超过 6 人。本大赛为开发者提供 OpenHarmony 开源项目的实践机会及经费资助,并有丰厚奖金及荣誉激励。

优秀的个人博客,低调大师

面对巨头的垄断欺凌,Earthly 毅然决然从 “闭源” 转开源

Earthly 是一个 CI/CD 框架,允许开发者在本地开发 CI/CD 管道,并在任何地方运行它们。Earthly 利用容器来执行管道。这使得它具有可独立、可重复、可移植和并行这样的特点。目前 Earthly 在 GitHub 的 Star 数量为 6.5K。 过去为了保护 Earthly 自己的利益,并围绕它建立一个可持续的业务,他们一直在使用 BSL(Business Source License,未获得 OSI 认可)这样的 source-available(源码可见)的许可证。BSL 类似于开源许可证,但有额外的限制,使用限制性更强的许可证主要原因就是为了防止竞争对手将你的产品作为一种服务来提供,而之前这种类型的许可证更主要地用于数据库领域。 自 2020 年年初首次提交代码以来,Earthly 已经走过了两个年头。根据官方社交媒体下方的互动信息来看,在过去两年时间里,Earthly 不断增长的用户群大多都对 BSL 许可证没有意见,但在少数情况下,BSL 许可证也会成为劝退部分用户的一个原因。 虽然 Earthly 在很短的时间内取得了快速增长,但也因为潜在用户对 BSL 协议不甚了解和 “恐惧” 限制了公司的成长,再加上他们希望 Earthly 能够成为任何 CI/CD 供应商的统一框架,他们需要一个更加开放的协议来拥抱社区并实现公司的愿景。因此,他们宣布 Earthly 将从 BSL 转为 MPL 2.0 开源许可证。 在项目作者的回复中,他表示: 我们转向开源,以更好地使我们与社区保持一致。面对科技巨头的垄断欺凌,这是一个艰难的决定,但我认为在这种情况下利大于弊。

优秀的个人博客,低调大师

JFinal 表自动绑定插件实现,实现零配置,支持多数据源

以mysql数据库实现为例,其它的db也可基于这种方式自己实现 大概的思路是这样的,为了简少配置,所以不使用注解的方式 首先需要一个工具类来拿到所有的Model类大体的实现方式如下 package com.nmtx.utils; import java.io.File; import java.util.ArrayList; import java.util.List; import com.jfinal.kit.PathKit; import com.jfinal.kit.StrKit; public class ClassUtils { public static String classRootPath = null; public static List<Class<?>> scanPackage(String packageName) throws ClassNotFoundException { List<Class<?>> classList = new ArrayList<Class<?>>(); String path = getClassRootPath() + "/" + packageName.replace(".", "/"); List<String> fileNameList = getAllFileName(path); for (String fileName : fileNameList) { classList.add(Class.forName(fileName)); } return classList; } public static List<String> getAllFileName(String path) { List<String> fileNameList = new ArrayList<String>(); File rootFile = new File(path); if (rootFile.isFile()) { String fileName = rootFile.getPath().replace(PathKit.getRootClassPath(), "").replace(File.separator, ".") .replaceFirst(".", ""); String prefix = fileName.substring(fileName.lastIndexOf(".") + 1); if (prefix.equals("class")) { fileNameList.add(fileName.substring(0, fileName.lastIndexOf("."))); } } else { File[] files = rootFile.listFiles(); if (files != null) { for (File file : files) { fileNameList.addAll(getAllFileName(file.getPath())); } } } return fileNameList; } public static String getClassRootPath() { if (StrKit.isBlank(classRootPath)) classRootPath = PathKit.getRootClassPath(); return classRootPath; } public static void setClassRootPath(String classRootPath) { ClassUtils.classRootPath = classRootPath; } } 有了工具类,就去处理自动扫描插件,大概实现是这样的 package com.nmtx.plugins.db; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import com.jfinal.kit.StrKit; import com.jfinal.plugin.IPlugin; import com.jfinal.plugin.activerecord.ActiveRecordPlugin; import com.jfinal.plugin.activerecord.Model; import com.jfinal.plugin.c3p0.C3p0Plugin; import com.nmtx.plugins.db.impl.TableToModelByUnderline; import com.nmtx.utils.ClassUtils; public class AutoTabelPlugin implements IPlugin { private String db; private ActiveRecordPlugin arp; private String pacekageName; private String idKey; private ITableToModelFormat tableToModelFormate; private C3p0Plugin c3p0Plugin; public AutoTabelPlugin(C3p0Plugin erpC3p0, ActiveRecordPlugin arp, String db, String packageName, String idKey, ITableToModelFormat tableToModelFormate) { this.db = db; this.arp = arp; this.idKey = idKey; this.tableToModelFormate = tableToModelFormate; this.c3p0Plugin = erpC3p0; } public AutoTabelPlugin(C3p0Plugin erpC3p0, ActiveRecordPlugin arp, String db, String packageName, String idKey) { this.db = db; this.arp = arp; this.idKey = idKey; this.pacekageName = packageName; this.tableToModelFormate = new TableToModelByUnderline(); this.c3p0Plugin = erpC3p0; } @SuppressWarnings({ "unchecked" }) public List<Class<? extends Model<?>>> getModelClass() throws ClassNotFoundException { List<Class<?>> classes = ClassUtils.scanPackage(pacekageName); List<Class<? extends Model<?>>> modelClasses = new ArrayList<Class<? extends Model<?>>>(); for (Class<?> classer : classes) { modelClasses.add((Class<? extends Model<?>>) classer); } return modelClasses; } public boolean start() { try { HashMap<String, String> tableMap = getTableMap(); List<Class<? extends Model<?>>> modelClasses = getModelClass(); for (Class<? extends Model<?>> modelClass : modelClasses) { String tableName = tableMap.get(modelClass.getSimpleName()); if (tableName != null) { if (StrKit.notBlank(idKey)) { arp.addMapping(tableName, idKey, modelClass); } else { arp.addMapping(tableName, modelClass); } } } } catch (ClassNotFoundException e) { throw new RuntimeException("auto table mappming is exception" + e); } return true; } /** * 获取Model和表名的映射 * * @return */ private HashMap<String, String> getTableMap() { HashMap<String, String> map = new HashMap<String, String>(); Connection connection = null; PreparedStatement preStatement = null; ResultSet resultSet = null; try { c3p0Plugin.start(); connection = c3p0Plugin.getDataSource().getConnection(); preStatement = connection.prepareStatement( "select table_name as tableName from information_schema.tables where table_schema='" + db + "' and table_type='base table'"); resultSet = preStatement.executeQuery(); while (resultSet.next()) { String tableName = resultSet.getString(1); map.put(tableToModelFormate.getTableByModel(tableName), tableName); } } catch (Exception e) { closeConnection(connection, preStatement, resultSet); throw new RuntimeException("auto table mappming is exception" + e); } finally { closeConnection(connection, preStatement, resultSet); } return map; } private void closeConnection(Connection connection, PreparedStatement preStatement, ResultSet resultSet) { try { if (resultSet != null) { resultSet.close(); } if (preStatement != null) { preStatement.close(); } if (connection != null) { connection.close(); } } catch (SQLException e) { throw new RuntimeException("auto close db connection is exception" + e); } } public boolean stop() { return true; } } 因为java里的属性一般都是驼峰规则,代码看起来舒服一点,这里以数据库中以大写字母为例,表名为T_USER,对应Model名为User实现如下 接口定义 package com.nmtx.plugins.db; public interface ITableToModelFormat { public String generateTableNameToModelName(String tableName); } 实现如下 package com.nmtx.plugins.db.impl; import com.nmtx.plugins.db.ITableToModelFormat; public class TableToModelByUnderline implements ITableToModelFormat{ public String generateTableNameToModelName(String tableName) { StringBuilder modelName = new StringBuilder(); tableName = tableName.substring(2).toLowerCase(); String tableNames[] = tableName.split("_"); for(String tableNameTemp:tableNames){ modelName.append(fisrtStringToUpper(tableNameTemp)); } return modelName.toString(); } private String fisrtStringToUpper(String string){ return string.replaceFirst(string.substring(0, 1),string.substring(0, 1).toUpperCase()); } } 如果不同的格式可以实现不同的方法,根据自己的需求,这样就完成了自动扫描插件,使用起来也方便如下 C3p0Plugin spuC3p0= new C3p0Plugin(getProperty("jdbc.mysql.url"), getProperty("jdbc.mysql.username").trim(), getProperty("jdbc.mysql.password").trim(), getProperty("jdbc.mysql.driverClass")); spuC3p0.setMaxPoolSize(Integer.parseInt(getProperty("jdbc.mysql.maxPool"))); spuC3p0.setMinPoolSize(Integer.parseInt(getProperty("jdbc.mysql.minPool"))); spuC3p0.setInitialPoolSize(Integer.parseInt(getProperty("jdbc.mysql.initialPoolSize"))); ActiveRecordPlugin spuArp = new ActiveRecordPlugin(DbConfigName.SPU, spuC3p0); AutoTabelPlugin spuAutoTabelPlugin = new AutoTabelPlugin(spuC3p0, spuArp, getProperty("jdbc.mysql.spu.db"), "com.nmtx.manager.model", "ID"); me.add(spuAutoTabelPlugin); me.add(spuArp); 如果有多个就可以配置多个插件,而无需在管映射了,新增Model直接新增即可,不要再管映射

资源下载

更多资源
Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册