您的位置:首页 > 运维架构 > 网站架构

网站后台开发常见BUG及解决方法

2017-11-21 22:59 330 查看
Bug-01

--------------------------------------------------

C:\Program Files\MariaDB 5.5\bin>mysql -u root -p;

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (

ES)

登录时去掉最后的";"

---------------------------------------------------------------------

Bug-02 

启动tomcat 出现如下问题:

java.sql.SQLException: 

Access denied for user 'root'@'localhost' (using password: NO)

step01:检测数据库配置文件中url,用户名,密码配置是否正确

假如配置都没有问题,还出现拒绝访问,如何解决?

step02:检测数据库服务器是否已经启动?

可以从mysql的客户端先登录一下试试,假如可以登录,说明服务已经启动

step03:重新执行maven update (强制更新)

重新执行了maven update多次,启动tomcat,还是报拒绝访问问题.

step04: 尝试更新数据库驱动并检测url中的端口号.

---------------------------------------------------------------------

Bug-03 

ttm1.0 项目登录以后,页面乱码出现乱码?

解决方案:

1)查询数据库表中内容

2)假如内容是乱码,则重新导入数据

step01: set names utf8

step02: source d:/ttms.sql

--------------------------------------------------------------------

Bug-04

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): cn.tedu.ttms.product.dao.ProjectDao.findObjects
at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:189)
at org.apache.ibatis.binding.MapperMethod.<init>

检测XxxMapping.xml文件中的内容配置是否有问题

1)namespace(命名空间)

2)resultType(映射结果类型)

3)id(值是否与dao中方法对应)

解决问题的思路:4w+h

 1)when  (执行什么操作出现的这个问题)

 2)what   (什么问题)

 3)where (哪里的问题,至少要看5行错误)

 4)why     (为什么会出现这个问题)

 5)how     (如何解决这个问题)

---------------------------------------------------------------

Bug05

org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: No serializer found for class cn.tedu.ttms.product.entity.Project and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS);
nested exception is com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class cn.tedu.ttms.product.entity.Project and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)
(through reference chain: java.util.ArrayList[0])
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.writeInternal(AbstractJackson2HttpMessageConverter.java:299)
at org.springframework.http.converter.AbstractGenericHttpMessageConverter.write(AbstractGenericHttpMessageConverter.java:106)

此问题一般是实体对象缺少get方法所导致

------------------------------------------------------------------

Bug-06

HTTP Status 404 - /ttms1.01/WEB-INF/pages/project/doFindObjects.jsp

查找控制层对应方法是否使用了@ResponseBody注解

------------------------------------------------------------------

Bug-07

org.mybatis.spring.MyBatisSystemException:

nested exception is org.apache.ibatis.binding.BindingException: Parameter 'startIndex' not found.

Available parameters are [0, 1, param1, param2]

atorg.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
at com.sun.proxy.$Proxy40.selectList(Unknown Source)

此异常为绑定异常,是在mybatis映射文件中通过#或$去获取startIndex的值时,没有找到这个参数,找到的是[0, 1, param1, param2].

解决方案:

1)在dao中通过@Param定义参数,mapper文件中通过

  #{startIndex}或${startIndex}

2)借助#{param1},...等形式在mapper文件中获取参数值

3)借助#{0},#{1},...等形式在mapper文件获取值.

----------------------------------------------------------------------

Bug-08

### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE  valid=0' at line 1

; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE  valid=0' at
line 1
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:231)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)

以后再遇到MySQLSyntaxErrorException时,先检测你的SQL语法.

--------------------------------------------------------------------

Bug-09 

浏览器的控制端出现:

Uncaught SyntaxError: unexpected token }

一般是JS代码中多或少了"}"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: