
java
文章平均质量分 75
程序媛-团子
Keep enpowering yourself successfully
展开
-
java下载网络图片文件,并获取其图片类型
业务场景:业务后台编辑资讯时候,从其他网页直接复制内容的时候,复制图片,部分图片由于前端跨域问题,无法展示,而且没法上传到本公司的资源文件服务;故需要后台下载图片资源文件,然后再进行上传本公司资源文件服务,再返回前端问题:由于网络上的图片路径各式各样,不能单纯通过外链接的后缀来判断图片的类型,如:https://hbimg.huabanimg.com/ff4aceaad9a05333b3e46579d991eecdcffb45f612951-T6WWCx_fw658/format/webp 、h原创 2021-02-24 16:52:01 · 1794 阅读 · 0 评论 -
springboot不同版本整合elasticsearch
使用springboot整合elasticsearch时候,需要注意版本的对应关系,不然问题会非常多,对应关系如下:springboot2.1整合elasticsearch的两个方式:通过spring-data-es(springboot 2.2版本以后使用http形式操作,使用端口9200,springboot 2.1使用tcp形式访问es,使用端口9300)、使用 RestHighLevelClient 方式使用RestHighLevelClient 方式,官方建议restHighLeve.原创 2020-05-13 14:06:11 · 6175 阅读 · 0 评论 -
nested exception is org.hibernate.boot.archive.spi.ArchiveException: Could not build ClassFile 问题解决
springboot启动报错:Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.2020-05-07 09:33:30 [ERROR] org.springframework.boot.SpringApplicati...原创 2020-05-07 09:42:29 · 3141 阅读 · 1 评论 -
java文件拷贝方式
java文件拷贝方式java.io提供了FileInputStream、FileOutputStream文件拷贝方式public static void copyFileByStream(File source, File dest) throws IOException { try (InputStream is = new FileInputStrea...原创 2020-03-26 15:54:43 · 500 阅读 · 0 评论 -
理解spring aop动态代理
Spring AOPSpring是一个轻型容器,Spring整个系列的最最核心的概念当属IoC、AOP(Aspect Oriented Programming,即面向切面编程)。Spring AOP的底层实现是基于动态代理的实现原理,AOP的拦截功能是由java中的动态代理来实现的。AOP的源码中用到了两种动态代理来实现拦截切入功能:jdk动态代理和cglib动态代理。jdk动态代理是由j...原创 2020-03-26 11:54:24 · 350 阅读 · 0 评论 -
springboot根据表名和字段查询和更新实现动态sql(jpa,mybatis)
最近需要做一个根据表名和字段更新表的功能,项目结构是springboot+jpa,记录如下:1.经查阅资料jpa和hibernate自带对原生sql的支持都是不支持该操作的,原因是:jpa和hibernate在进行参数替换的时候是使用占位符的形式,防止了sql的注入,在解析会给参数带上单引号,但是可以通过定义原生的sql进行解决动态sql查询,但无法实现动态sql更新,如果需要更新必须获取到表对应...原创 2018-07-12 17:00:10 · 17714 阅读 · 3 评论 -
mybatis连接mysql断连接问题记录
1.mybatis提供的数据源类型 以下是官网介绍 UNPOOLED 不使用连接池的数据源 This implementation of DataSource simply opens and closes a connection each time it is requested. While it’s a bit slower, this is ...原创 2018-06-26 11:27:48 · 3518 阅读 · 2 评论 -
ideamaven打包模块项目依赖出现问题记录
情况:项目开发有四个mavenmodule模块,分别为ABCD,其中ABD打包后均为jar,C为springboot项目结构,而ABC均依赖D模块,在使用maven package打包发现,C项目能把D项目作为依赖打包进来,而AB均只打包了各自文件并未打包C,导致运行AB时出现错误出现错误原因:使用maven默认的package命令构建的jar包中只包括了工程自身的class文件,并没有包括依赖的...原创 2018-06-14 19:44:15 · 3512 阅读 · 0 评论 -
线程安全单例模式
package com.tnaot.newshandle.base.oss;import com.aliyuncs.DefaultAcsClient;import com.aliyuncs.IAcsClient;import com.aliyuncs.profile.DefaultProfile;import com.tnaot.newshandle.base.config.OSSCon...原创 2018-06-06 17:04:56 · 850 阅读 · 0 评论 -
使用jdbc连接数据库
1.数据库连接工具类/** * Author: hezishan * Date: 2018/5/15. * Description: **/public class DBUtils { //资源文件 static Properties pros = null; //静态初始化 当加载JDBCUtil类时调用 static { pros ...原创 2018-05-16 14:37:38 · 242 阅读 · 0 评论 -
quartz定时任务
一、简单介绍quartz 1. 定时器种类 Quartz 中五种类型的 Trigger:SimpleTrigger,CronTirgger,DateIntervalTrigger,NthIncludedDayTrigger和Calendar 类( org.quartz.Calendar)。 最常用的: SimpleTrigger:用来触发只需执行一次或者在给定时间触发并且重复N次且每次执行延...原创 2018-05-05 17:45:57 · 410 阅读 · 0 评论