hutool的一个奇怪现象,main ERROR Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...

hutool有一个强大的功能,一行代码实现增删改查。

在src/main/resources目录增加一个db.settings配置文件:

复制代码
url = jdbc:mysql://localhost:3306/ujcms?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
user = root
pass = root

## 可选配置 # 是否在日志中显示执行的SQL showSql = true # 是否格式化显示的SQL formatSql = false # 是否显示SQL参数 showParams = true # 打印SQL的日志等级,默认debug,可以是info、warn、error sqlLevel = debug
复制代码

 

然后用下面的代码就可以获取table1的实体对象。

List<Entity> table1 = Db.use().findAll("table1");

获取一个行对象,get方法中的数字是行号。

Entity rowEntity = ujcms_article.get(1);

获取某个字段的值:

String fieldValue = (String)rowEntity.get("fieldName");

 

pom.xml中的第三项tess4j是我没想到的,如果不加它,会报以下错误:

main ERROR Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...

而按照这个提示,去增加log4j-core的引用,会提示以下错误:

Thread-1 ERROR Could not register mbeans java.util.ConcurrentModificationException

不同的版本还有不同的错误,尝试了很多版本,都不能正常工作。

直到增加了tess4j的引用……

至于发现tess4j,还是因为一个意外,是在另一个项目中使用Hutool的这个功能时,发现那个项目是可以正常使用的,那时只道是寻常,直到这次发现不寻常。所以把那个项目的pom.xml中的内容全部复制过来,一个一个排除,最终发现了只有tess4j存在的时候,才能正常使用,百思不得其姐。

 ==============================

官方回复说tess4j引用的某个jar包恰好是hutoo所需要的。

posted @   火军刀  阅读(88)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示