常见问题记录


项目编译报错(无setter、getter方法)

问题描述

git clone DBlog后,ide打开提示编译报错,发现实体类中缺少setter和getter方法,这是因为DBlog中使用了lombok插件所致,只需要安装对应的lombok插件即可。

解决方案:

eclipse安装lombok

idea安装lombok: file->settings->plugins->Browse Repositories->输入lombok,点击搜索->选中lombok点击install->安装完成后重启idea

进阶版问题: idea中安装完lombok并重启idea之后,启动项目仍然报错: 输入图片说明 解决办法 输入图片说明 默认是eclipse 选择javac就可以了

该解决方案贡献者:Cary Lau

SQL异常(GROUP BY关键字)

问题描述

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #20 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'c.commentCount' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
...
...

解决方案

注意,异常提示中的 sql_mode=only_full_group_by ,这是MySQL 5.7.9版本sql_mode=only_full_group_by问题,请参考以下文章:

https://www.cnblogs.com/jim2016/p/6322703.html https://www.cnblogs.com/grimm/p/5751911.html

Redis异常

问题描述

org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
    at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:204)
    at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:348)
    at org.springframework.data.redis.core.RedisConnectionUtils.doGetConnection(RedisConnectionUtils.java:129)
    at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:92)
    at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:79)
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:194)
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:169)
    at org.springframework.data.redis.core.RedisTemplate.hasKey(RedisTemplate.java:658)
...
...

解决方案

DBlog博客依赖于Redis,请参考【使用说明】修改redis配置

特别提醒:如果redis未设置密码,可把配置文件中redis的password配置直接注释掉!!

百度分享无法使用

输入图片说明

将上图所示,js部分的代码,copy到article.ftl页面中,获取代码

文章推送功能不可用

输入图片说明

如果看到上面提示,则表示项目里为设置站长平台的Cookie,(Cookie配置类:BaiduPushUtil.java

获取百度站长平台的Cookie,点我。登录成功后,将下图所示的cookie按照key=value;key=value;的格式全部copy到BaiduPushUtil.java输入图片说明 或者可以直接copy这个 输入图片说明

Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded datasource could be auto-configured.

问题描述

启动报错:

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded datasource could be auto-configured.

Reason: Failed to determine a suitable driver class


Action:

Consider the following:
    If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
    If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

解决方案

1.资源拷贝的问题,检查一下打包后的target/classes文件夹是否存在配置文件

解决办法:

如果存在application.yml存在,多半是application.yml编码格式的问题,文件编码改成utf-8 输入图片说明

其他问题