freemarker循环、日期格式化、常用汇总
星期六, 2020-08-15 | Author: Lee | JAVA-and-J2EE, spring-boot | 2 Comments 333 views
首先权威地址官方地址:https://freemarker.apache.org/
中文版使用手册地址:http://freemarker.foofun.cn/toc.html
1.日期格式及解决日期为NULL报错的写法
${(user.birthday?string("yyyy-MM-dd"))!} //--或者-- ${(user.birthday?string("yyyy-MM-dd"))!'--'} |
2.判断对象是否存在再进行操作
<#if user?? >「${user.name }」<#else>无</#if> |
3.循环及计数使用
<#list listUser as user> <#if user?? >「${user.name }」<#else>无</#if> <#if user?counter gt 3 > ${user.email} </#if> </#if> |
防止selenium和ChromeDriver的JS检测java版处理
星期一, 2020-07-27 | Author: Lee | JAVA-and-J2EE, linux | 没有评论 775 views
启用最新版本的 selenium-java的4.0.0-alpha-X版本即可支持CdpCommand抵挡 webdriver的检测为true
maven如下:
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java --> <dependency> <groupid>org.seleniumhq.selenium</groupid> <artifactid>selenium-java</artifactid> <version>4.0.0-alpha-6</version> </dependency> <dependency> <groupid>com.google.guava</groupid> <artifactid>guava</artifactid> </dependency> |
对应java代码如下
› 继续阅读
springboot的瘦身部署计划lib依赖包分离
星期二, 2020-06-30 | Author: Lee | JAVA-and-J2EE, linux | 没有评论 568 views
1.springboot目前都趋向于使用jar部署,但是问题是每次打包的
fatjar都比较大,有50M左右,发布上传比较耗时,尤其是服务器在海外的情况更是感觉浪费时间
2.把依赖的lib包剥离出来,单独依赖减少每次的打包大小量
注意:若有新增加的依赖或者调整依赖库的版本需要重新调整lib,切记.
3.开始方法:正常打包 获取BOOT-INF下的lib依赖jar包
mvn clean install
› 继续阅读
修改eclipse默认注释日期显示中文(上午下午)的问题
星期二, 2020-06-23 | Author: Lee | JAVA-and-J2EE, linux | 没有评论 547 views
默认注释${date} 会显示上午 下午等中文 现在可以自定义格式了
windows -> preferences -> java -> code style -> code template -> Comments ->Types /** * @author pomelo.lee * @date ${currentDate:date('yyyy-MM-dd HH:mm:ss')} */ |
想要所有的都显示英文 可以在启动eclipse加语言参数控制,只是日期的话已经不需要了
eclipse的安装目录上找到eclipse.ini文件,加入:
-Duser.language=en_US |
开启virtualbox端口映射,使用ssh连接
星期二, 2020-06-16 | Author: Lee | computer, JAVA-and-J2EE, linux | 没有评论 396 views
1.如果有条件可以开启虚拟机的桥接网卡的模式
自动获取路由器的IP地址,则可以自由连接
2.如果只是网络地址转换(NAT)
通过配置端口转发,实现ssh软件的连接
如下图:(IP:127.0.0.1 PORT:1022端口即可连接)
Linux-socket内核参数配置及含义详解
星期一, 2020-06-08 | Author: Lee | JAVA-and-J2EE, linux | 没有评论 482 views
多由于Linux下解决time_wait连接过多(Linux内核优化配置)
内核文件配置:
vi /etc/sysctl.conf ##生效 /sbin/sysctl -p ##查看keepalive的相关配置 sysctl -a | grep keepalive ##查看tcp连接的相关状态指令 netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}' ##若没有netstat指令安装 yum install net-tools |
内核配置注释信息,参考自己的内存和CPU核数进行优化配置,如下
› 继续阅读
centos查询大于100M文件命令
星期三, 2020-06-03 | Author: Lee | JAVA-and-J2EE, linux | 没有评论 344 views
centos 查询大于100M文件及列出
ls -lh $(find / -type f -size +100M) |
spring boot aop log拦截配置
星期一, 2020-05-25 | Author: Lee | JAVA-and-J2EE | 没有评论 401 views
要记录web的入参和出参及方法执行情况,执行如下配置即可
package com.pomelolee.configuration; import lombok.extern.slf4j.Slf4j; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import org.apache.commons.lang3.StringUtils; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.reflect.MethodSignature; import org.springframework.stereotype.Component; import org.springframework.util.StopWatch; import org.springframework.web.multipart.MultipartFile; @Slf4j @Aspect @Component public class WebControllerLogConfig { @Pointcut("execution(public * com.pomelolee.endpoint.*.*(..))") public void webRecordLog() { } @Around("webRecordLog()") public Object process(ProceedingJoinPoint jp) throws Throwable { String className = jp.getSignature().getDeclaringTypeName(); String methodName = ((MethodSignature) jp.getSignature()).getMethod().getName(); String classMethod = className + "." + methodName; Object[] arguments = jp.getArgs(); Object[] args = new Object[arguments.length]; for(int i=0;i<arguments.length;i++) { if (arguments[i] instanceof ServletRequest || arguments[i] instanceof ServletResponse || arguments[i] instanceof MultipartFile) { //ServletRequest不能序列化,从入参里排除,否则报异常:java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false) //ServletResponse不能序列化 从入参里排除,否则报异常:java.lang.IllegalStateException: getOutputStream() has already been called for this response continue; } args[i] = arguments[i]; } log.info("===controller classMethod:{},input args:{} ====", classMethod, JsonKit.toJSONString(args)); final StopWatch stopWatch = new StopWatch(); stopWatch.start(); Object result = jp.proceed(); stopWatch.stop(); final String logMessage = StringUtils.leftPad(Long.toString(stopWatch.getTotalTimeMillis()), 5) + " ms "; log.info("the classMethod: {} cost time: {}",classMethod,logMessage); log.info("===controller classMethod: {} ,input args:{} ====", classMethod, JsonKit.toJSONString(result)); return result; } } |
比较完整,排除了 out等输出的异常情况
VirtualBox下centos7修复generating /run/initramfs/rdsosreport.txt无法启动问题
星期二, 2020-04-28 | Author: Lee | computer, linux | 没有评论 1,488 views
开机就进入命令窗口,窗口提示信息如下,无法进入系统,让人头大:
generating “/run/initramfs/rdsosreport.txt”
entering emergencymode. exit the shell to continue
type “journalctl” to view system logs.
you might want to save “/run/initramfs/rdsosreport.txt” to a usb stick or /boot after mounting them and attach it to a bug report。
解决办法的命令如下:
xfs_repair /dev/mapper/centos-root -L reboot |
springboot的关闭eureka注册中心服务
星期日, 2020-04-26 | Author: Lee | JAVA-and-J2EE | 没有评论 865 views
1.本地调试的时候不希望注册到eureka上影响其他服务的调用
可以配置applicatioon.properties文件添加对应的配置即可
eureka.client.register-with-eureka=false eureka.client.fetchRegistry=false eureka.client.server.waitTimeInMsWhenSyncEmpty=0 |
启动应用服务,可以到对应的注册中心(http://localhost:8761/eureka)查看,没有注册上来,ok
Search
相关文章
热门文章
最新文章
文章分类
- ajax (9)
- algorithm-learn (2)
- Android (6)
- as (3)
- computer (54)
- Database (29)
- disucz (4)
- enterprise (1)
- erlang (2)
- flash (4)
- golang (3)
- html5 (18)
- ios (4)
- JAVA-and-J2EE (158)
- linux (121)
- mac (6)
- movie-music (11)
- pagemaker (35)
- php (49)
- spring-boot (2)
- Synology群晖 (2)
- Uncategorized (6)
- unity (1)
- webgame (15)
- wordpress (33)
- work-other (1)
- 体味生活 (40)
- 大数据 (4)
- 游戏开发 (9)
- 爱上海 (19)
- 读书 (4)
- 软件 (3)