首页 文章 精选 留言 我的

精选列表

搜索[多云部署],共10000篇文章
优秀的个人博客,低调大师

mybatis mapper.xml 热部署

package com.guangeryi.mall.core.utils.mybatis; import com.guangeryi.mall.common.CommonConstant; import com.guangeryi.mall.core.utils.StringUtils; import org.apache.ibatis.binding.MapperProxyFactory; import org.apache.ibatis.session.Configuration; import org.apache.ibatis.session.SqlSessionFactory; import org.apache.logging.log4j.util.Strings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeansException; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.core.io.Resource; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.stereotype.Component; import java.io.IOException; import java.lang.reflect.Field; import java.util.*; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @Component public class MyBatisMapperRefresher implements DisposableBean, InitializingBean, ApplicationContextAware { private final Logger logger = LoggerFactory.getLogger(getClass()); /** * 扫描周期,单位秒 */ private int periodSeconds = 5; /** * 初始化完成,延迟扫描时间,单位秒 */ private int initialDelay = 5; /** * 是否启用 */ @Value("${mapper.auto.load}") private boolean enabled; private ConfigurableApplicationContext context = null; private transient Resource[] basePackage = null; private HashMap<String, String> fileMapping = new HashMap<>(); private Set<String> isChangedMapper = new HashSet<>(); private Scanner scanner = null; private ScheduledExecutorService service = null; @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.context = (ConfigurableApplicationContext) applicationContext; } @Override public void afterPropertiesSet() throws Exception { if (!enabled) { logger.info("MyBatisMapperRefresher is Disabled"); return; } try { service = Executors.newScheduledThreadPool(1); PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); basePackage = resolver.getResources("classpath*:xx.xml");// 加载配置xml文件 logger.info("监控以下" + basePackage.length + "个xml文件:"); // 触发文件监听事件 scanner = new Scanner(); scanner.scan(); service.scheduleAtFixedRate(new Task(), MyBatisMapperRefresher.this.initialDelay, MyBatisMapperRefresher.this.periodSeconds, TimeUnit.SECONDS); } catch (Exception e1) { logger.error("can not starter Mybatis xml refresher,exception:{}", e1); } } class Task implements Runnable { @Override public void run() { try { if (scanner.isChanged()) { scanner.reloadXML(); } } catch (Exception ex) { logger.error("MyBatisMapperRefresher,exception:{}", ex); } } } @Override public void destroy() throws Exception { if (service != null) { service.shutdownNow(); } } class Scanner { private Resource[] mapperXmlFiles; public Scanner() { mapperXmlFiles = MyBatisMapperRefresher.this.basePackage; } public void reloadXML() throws Exception { SqlSessionFactory factory = context.getBean(SqlSessionFactory.class); Configuration configuration = factory.getConfiguration(); Set<Class<?>> knownMapperKeys = new HashSet<>(); Field field = configuration.getMapperRegistry().getClass().getDeclaredField("knownMappers"); field.setAccessible(true); Map<Class<?>, MapperProxyFactory<?>> knownMappers = (Map<Class<?>, MapperProxyFactory<?>>) field.get(configuration.getMapperRegistry()); knownMapperKeys.addAll(knownMappers.keySet()); // 移除加载项 removeConfig(configuration, isChangedMapper); Set<String> isChangedMapperTemp = isChangedMapper.stream().map(item -> StringUtils.split(item, CommonConstant.CHAR_SPOT)[0]).collect(Collectors.toSet()); Iterator<Class<?>> classIterator = knownMapperKeys.iterator(); while (classIterator.hasNext()) { Class clazz = classIterator.next(); if (clazz == null || Strings.isEmpty(clazz.getName())) continue; String[] clazzNames = StringUtils.split(clazz.getName(), CommonConstant.CHAR_SPOT); if (isChangedMapperTemp.contains(clazzNames[clazzNames.length - 1])) { knownMappers.remove(clazz); configuration.addMapper(clazz); } } isChangedMapper.clear(); } private void removeConfig(Configuration configuration, Set<String> isChangedMapper) throws Exception { Class<?> classConfig = configuration.getClass(); clearMap(classConfig, configuration, "mappedStatements", isChangedMapper); clearMap(classConfig, configuration, "caches", isChangedMapper); clearMap(classConfig, configuration, "resultMaps", isChangedMapper); clearMap(classConfig, configuration, "parameterMaps", isChangedMapper); clearMap(classConfig, configuration, "keyGenerators", isChangedMapper); clearMap(classConfig, configuration, "sqlFragments", isChangedMapper); clearSet(classConfig, configuration, "loadedResources", isChangedMapper); } private void clearMap(Class<?> classConfig, Configuration configuration, String fieldName, Set<String> isChangedMapper) throws Exception { Set<String> isChangedMapperTemp = isChangedMapper.stream().map(item -> "repository." + StringUtils.split(item, CommonConstant.CHAR_SPOT)[0]).collect(Collectors.toSet()); Field field = classConfig.getDeclaredField(fieldName); field.setAccessible(true); Map mapConfig = (Map) field.get(configuration); Map tempMap = new HashMap(); tempMap.putAll(mapConfig); tempMap.forEach((key, value) -> { if (StringUtils.StringContains((String) key, isChangedMapperTemp)) mapConfig.remove(key); }); } private void clearSet(Class<?> classConfig, Configuration configuration, String fieldName, Set<String> isChangedMapper) throws Exception { Set<String> isChangedMapperTemp = isChangedMapper.stream().map(item -> "repository/" + StringUtils.split(item, CommonConstant.CHAR_SPOT)[0]).collect(Collectors.toSet()); isChangedMapperTemp.addAll(isChangedMapper.stream().map(item -> "repository." + StringUtils.split(item, CommonConstant.CHAR_SPOT)[0]).collect(Collectors.toSet())); Field field = classConfig.getDeclaredField(fieldName); field.setAccessible(true); Set setConfig = (Set) field.get(configuration); Set tempMap = new HashSet<>(); tempMap.addAll(setConfig); tempMap.forEach(item -> { if (StringUtils.StringContains((String) item, isChangedMapperTemp)) setConfig.remove(item); }); } public void scan() throws IOException { if (!fileMapping.isEmpty()) { return; } Resource[] resources = mapperXmlFiles; if (resources != null) { for (int i = 0; i < resources.length; i++) { String multi_key = getValue(resources[i]); String fileName = resources[i].getFilename(); fileMapping.put(fileName, multi_key); logger.info("monitor Mybatis mapper file:{}", resources[i].getFile().getAbsolutePath()); } } } private String getValue(Resource resource) throws IOException { String contentLength = String.valueOf((resource.contentLength())); String lastModified = String.valueOf((resource.lastModified())); return new StringBuilder(contentLength).append(lastModified).toString(); } public boolean isChanged() throws IOException { boolean isChanged = false; Resource[] resources = mapperXmlFiles; if (resources != null) { for (int i = 0; i < resources.length; i++) { String name = resources[i].getFilename(); String value = fileMapping.get(name); String multi_key = getValue(resources[i]); if (!multi_key.equals(value)) { isChanged = true; fileMapping.put(name, multi_key); isChangedMapper.add(name); logger.info("reload Mybatis mapper file:{}", resources[i].getFile().getAbsolutePath()); } } } return isChanged; } } } 希望园友多多提意见...

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

Docker部署centos7容器

操作系统:centos7.2.1511 centos镜像:centos7.2.1511 安装docker yum -y install docker 启动docker systemctl start docker 发现启动不了,报错: Error starting daemon: SELinux is not supported with the overlay2 graph driver on this kernel. Either boot into a newer kernel or disable selinux ...enabled=false) 修改配置文件 vim /etc/sysconfig/docker OPTIONS='--selinux-enabled=false' 再次启动服务 systemctl start docker systemctl status docker ● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled) Active: active (running) since Tue 2018-07-17 05:48:54 CST; 20s ago Docs: http://docs.docker.com 下载centos7.2镜像 docker pull daocloud.io/library/centos:centos7.2.1511 docker images REPOSITORY TAG IMAGE ID CREATED SIZE daocloud.io/library/centos centos7.2.1511 0a2bad7da9b5 8 months ago 195 MB Systemd整合 因为 systemd 要求 CAPSYSADMIN 权限,从而得到了读取主机 cgroup 的能力,CentOS7 中已经用 fakesystemd 代替了 systemd 来解决依赖问题,如果仍然希望使用 systemd,可用下面的 Dockerfile cat > Dockerfile <<EOF FROM 0a2bad7da9b5 MAINTAINER Testder 10000@testder.cn ENV container docker RUN yum -y swap -- remove fakesystemd -- install systemd systemd-libs RUN yum -y update; yum clean all; \ (cd /lib/systemd/system/sysinit.target.wants/; for i in *;\ do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ rm -f /lib/systemd/system/multi-user.target.wants/*;\ rm -f /etc/systemd/system/*.wants/*;\ rm -f /lib/systemd/system/local-fs.target.wants/*; \ rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ rm -f /lib/systemd/system/basic.target.wants/*;\ rm -f /lib/systemd/system/anaconda.target.wants/*; VOLUME [ "/sys/fs/cgroup" ] CMD ["/usr/sbin/init"] EOF 构建基础镜像 docker build --rm -t centos7.2 . 后台运行Centos容器 为了运行一个包含 systemd 的容器,您需要使用–privileged选项, 并且挂载主机的 cgroups 文件夹。 下面是运行包含 systemd 容器的示例命令: docker run -itd --name centos7.2 --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro centos7.2 641f23dce23355729dfb8e99e5df467574eb116afbb1c50e71e272e952451d03 使用exec进入Centos容器,systemd启动成功 docker exec -it centos7.2 /bin/bash [root@641f23dce233 /]# yum -y install httpd [root@641f23dce233 /]# systemctl start httpd

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

CentOS 7安装和部署Docker

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010046908/article/details/79553227 Docker 要求 CentOS 系统的内核版本高于 3.10 ,查看本页面的前提条件来验证你的CentOS 版本是否支持 Docker 。通过 uname -r 命令查看你当前的内核版本 uname -r centos版本 3.10.0-514.el7.x86_64 1、初步安装和启动docker yum update -y yum -y install docker systemctl start docker 2、设置镜像 vi /etc/docker/daemon.json { "registry-mirrors": ["https://aj2rgad5.mirror.aliyuncs.com"] } 3、开放管理端口映射 vi /lib/systemd/system/docker.service 将第11行的ExecStart=/usr/bin/dockerd,替换为: ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock -H tcp://0.0.0.0:7654 2375是管理端口,7654是备用端口 在~/.bashrc中写入docker管理端口 export DOCKER_HOST=tcp://0.0.0.0:2375 source ~/.bashrc 4、重启docker systemctl daemon-reload systemctl restart docker.service 5、测试docker是否正常安装和运行 docker run hello-world 6、查看结果 Hello from Docker! This message shows that your installation appears to be working correctly.

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

EduSoho:免费部署在线学习平台

版权声明:转载请注明出处:http://blog.csdn.net/dajitui2024 https://blog.csdn.net/dajitui2024/article/details/79396608 EduSoho帮助培训机构和个人以最低成本、最快速度建立自己的在线教学网站,采用PHP 5开发,使用mysql数据库。 框架使用Symfony2.3 的视图层 + 自主研发的服务容器框架。更多帮助文档:http://www.edusoho.com/helphttp://www.qiqiuyu.com/ 1、基础配置: 官方推荐的配置是LNMP,即Linux+Nginx+MySQL+PHP 选择操作系统(Linux) 推荐使用Ubuntu,Fedora,CentOS,Gentoo。 选择Web服务器(Nginx或Apache2) Web服务器,官方推荐:Nginx或Apache2。关于Nginx:下载地址: http://nginx.org/en/download.html版本推荐: 1.0以上关于Apache2:下载地址: http://httpd.apache.org/download.cgi推荐版本: 2.0以上 选择MySQL数据库 MySQL数据库推荐版本:5.0以上。下载地址:http://www.mysql.com/downloads 选择PHP版本 版本: >= 5.5.0下载地址:http://cn2.php.net/downloads.php 注意:1. Linux 下需要关闭SeLinux ,不然安装完成页面会空白2.Nginx.conf中一定要配置client_max_body_size, 不然上传大文会卡住时 详细配置文档指导: Ubuntu14.04+Nginx+PHP+MySQL+EduSoho[推荐-标准环境-文档]Ubuntu 14.04+Apache+PHP+MySQL+EduSoho[文档]Ubuntu 12.04/14.04 以及 CentOS 6.x 一键安装EduSoho [推荐 - 快捷安装]Ubuntu14.04,使用Docker一键安装EduSohoCentOS 6.x + Nginx + PHP + MySQL + EduSoho[文档]CentOS 6.x + Apache+ PHP + MySQL + EduSoho[文档]CentOS 7 + Nginx + PHP + MySql + EduSohoCentOS 7 + Apache + PHP + MySql + EduSoho已预装EduSoho的Ubuntu 14.04 VMWare虚拟机AMH+LAMP安装EduSohoAMH+LNMP安装EduSohoWDCP + CentOS 6.x + EduSoho + Nginx

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

HttpRunner环境部署-踩坑篇

1、git clonehttps://github.com/HttpRunner/HttpRunner.git到本地 2、查看目前正在使用的Python版本:pyenv versions,默认只有system 3、查看可以安装的Python版本 pyenvinstall--list 4、官方建议Python3.6版本,so,安装需要的Python版本 pyenv install 3.6.2 5、切换Python版本,将Python 3.6.2置为默认 pyenv global 3.6.2, *号代表默认版本 特别建议: 优先级关系:shell——local——global 6、启动服务 需要Flask-Script支持 iwm@bogon  ~  pip install Flask-Script zsh: command not found: pip 7、提示找不到pip命令 iwm@bogon  /usr/local/Cellar  sudo easy_install pip 8、安装Flask-Script失败,error: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/itsdangerous.py' iwm@bogon  /usr/local/Cellar  pip install Flask-Script Collecting Flask-Script Downloading Flask-Script-2.0.6.tar.gz (43kB) 100% |████████████████████████████████| 51kB 103kB/s Collecting Flask (from Flask-Script) Downloading Flask-0.12.2-py2.py3-none-any.whl (83kB) 100% |████████████████████████████████| 92kB 110kB/s Collecting itsdangerous>=0.21 (from Flask->Flask-Script) Downloading itsdangerous-0.24.tar.gz (46kB) 100% |████████████████████████████████| 51kB 148kB/s Collecting Werkzeug>=0.7 (from Flask->Flask-Script) Downloading Werkzeug-0.14.1-py2.py3-none-any.whl (322kB) 100% |████████████████████████████████| 327kB 36kB/s Collecting Jinja2>=2.4 (from Flask->Flask-Script) Downloading Jinja2-2.10-py2.py3-none-any.whl (126kB) 100% |████████████████████████████████| 133kB 44kB/s Collecting click>=2.0 (from Flask->Flask-Script) Downloading click-6.7-py2.py3-none-any.whl (71kB) 100% |████████████████████████████████| 71kB 29kB/s Collecting MarkupSafe>=0.23 (from Jinja2>=2.4->Flask->Flask-Script) Downloading MarkupSafe-1.0.tar.gz Installing collected packages: itsdangerous, Werkzeug, MarkupSafe, Jinja2, click, Flask, Flask-Script Running setup.py install for itsdangerous ... error Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/4v/19tb9yfs367804yt2wzd7vjh0000gp/T/pip-build-6iVE3v/itsdangerous/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/4v/19tb9yfs367804yt2wzd7vjh0000gp/T/pip-zQxmry-record/install-record.txt --single-version-externally-managed --compile: running install running build running build_py creating build creating build/lib copying itsdangerous.py -> build/lib running install_lib copying build/lib/itsdangerous.py -> /Library/Python/2.7/site-packages error: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/itsdangerous.py' ---------------------------------------- Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/4v/19tb9yfs367804yt2wzd7vjh0000gp/T/pip-build-6iVE3v/itsdangerous/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/4v/19tb9yfs367804yt2wzd7vjh0000gp/T/pip-zQxmry-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/4v/19tb9yfs367804yt2wzd7vjh0000gp/T/pip-build-6iVE3v/itsdangerous/ 9、chomd赋予权限 sudo chmod 777 /Library/Python/2.7/site-packages/ 10、再次执行pip install Flask-Script 11、若第七步报如下错误,使用:pip --trusted-hostpypi.python.orginstall Flask-Script 12、启动httprunner,提示未发现HttpRunner强依赖的'PyUnitReport' 13、install PyUnitReport 14、install PyYAML 15、install requests 16、install pyOpenSSL 17、hrun -V 18、cd httprunner根目录下,执行export FLASK_APP=tests/api_server.py 19、接着执行flask run 遇到的问题: bogon:libexec luxiaoying$ pip install HttpRunner/usr/local/Cellar/pyenv/1.2.1/pyenv.d/exec/pip-rehash/pip: /usr/local/bin/pip: /usr/local/Cellar/python3/3.6.4_2/bin/python3.6: bad interpreter: No such file or directory 问题原因: 使用pyenv 安装了Python 3.6.4版本,并设置为默认,但提示告知Cellar下面并没有Python3。 拿Android举个例子吧,上面这种情况就像是我们只下载了某个版本的Android api,但却没有安装Android SDK 也就是说,具体版本是要依赖于某个开发环境而存在的 解决方案: 使用 brew install python3 命令安装Python3环境,如下图所示。安装成功后再次运行:pip install HttpRunner ,错误消失。

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

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文件系统,支持十年生命周期更新。

用户登录
用户注册