springmvc项目搭建过程中遇到的BUG及其解决方法

需要导入对应的类/jar包


没有找到该类,说明没有编译成功,

java.lang.ClassNotFoundException

org.springframework.web.util.Log4jConfigListener

*spring-web-3.2.8.RELEASE.jarlog4j-1.2.17.jar

oracle.jdbc.driver.OracleDriver

*导入的log4j.properties里面自动配置了数据库jar包需注释掉

org.springframework.expression.PropertyAccessor

*spring-expression-3.2.8.RELEASE.jar

org.springframework.web.servlet.view.InternalResourceViewResolver

*文字编写错误(resolver写成reslover

org.apache.commons.logging.Log

*commons-logging-1.1.1.jar



找不到相应的类文件
java.lang.NoClassDefFoundError

org/springframework/util/MultiValueMap

*spring-core-3.2.8.RELEASE.jar

org/apache/commons/logging/LogFactory

*commons-logging-1.1.1.jar

要显示sql日志还需要同时引入

*log4j-1.2.17.jar  和 *slf4j-api-1.7.5.jar   *slf4j-log4j12-1.7.5.jar


org/springframework/beans/factory/BeanNameAware

*spring-beans-3.2.8.RELEASE.jar

org/springframework/context/EnvironmentAware

*spring-context-3.2.8.RELEASE.jar

org.springframework.web.servlet.DispatcherServlet

*spring-webmvc-3.2.8.RELEASE.jar

Lorg/apache/commons/logging/Log

*commons-logging-1.1.1.jar

org/apache/commons/fileupload/FileItemFactory

*commons-fileupload-1.3.1.jar//因为在spring-servlet中设置了图片大小


//找不到对应的jar包   原因可能是未导入jar包或是引入文件的路径有误

org.apache.jasper.JasperException

The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application

*jstl.jar和 *standard.jar

java.lang.NoSuchFieldError: deferredExpression

*lib中有1个以上的JSTL包,删除一个即可



数据库及查询异常

java.sql.SQLException: Access denied for user 'propok'@'192.168.0.136' (using password: NO)
Access denied for user 'prosoftAngle'@'%' to database 'xxxdb'

//数据库连接不上(检测账号-密码-数据库)


//要查询一个对象时,查询出了2条或是多条,原因:1、插入时重复插入(验重),2、Sql没写好(查询数据有误)

org.apache.ibatis.exceptions.TooManyResultsException: 

Expected one result (or null) to be returned by selectOne(), but found: 2


//系统参数错误,执行的参数有误,( dao.selectOne("User",id)dao.selectOne("user",id) )

org.apache.ibatis.exceptions.PersistenceException:

Error querying database.Cause: java.lang.IllegalArgumentException:



SVN异常

svn: Working copy 'G:\workspace\52exun\WebRoot' locked; try performing 'cleanup'?

Some of selected resources were not committed.
svn: Working copy 'C:\project\xxxxx\xxxxx-web\test'
locked; try performing 'cleanup'
// 找到这个test(项目)路径打开 [.svn]文件夹 ,发现里面有[lock]和[log]文件
// 1. 删除lock文件    2 .删除log文件   3. clean up


svn: Commit failed (details follow):

//文件路径未找到,可能原因,文件改动后想提交时,别人已经改动提交,需更新下

svn: File '/crowdfund/WebRoot/WEB-INF/jsp/include/meta.jsp' is out of date


Spring及其SpringMVC异常


如果通过spring封装form表单数据后,后台得到的值为 乱码 ,除了 web.xml 设置 字符集过滤器外
还要对tomcat中的servlet里面的配置进行修改 添加URIEncoding="UTF-8"
   <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" URIEncoding="UTF-8" />

com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column “title” row 1//数据库字段长度不够,不一定是“title”,可能是同时插入的其他字段

<span style="color:#33ccff;">The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application </span>
*将jstl-1.2.jar复制到tomcat下面对应的lib中

请求参数异常

HTTP----400-
The request sent by the client was syntactically incorrect.

//方法参数跟传递参数不符



//通过首页跳转链接到 指定的新首页

<%@ page language="java"  session="false" %>

<%

// response.sendRedirect(response.encodeURL(request.getContextPath()+"/index"));

request.getRequestDispatcher("user/findAll").forward(request, response);

%>



easyUI异常

Uncaught TypeError:

Cannot read property 'length' of undefined

//分页属性 list<E> rows  只支持rows  不支持 其他参数

Cannot read property 'replace' of undefined

//在JS中使用replace代替函数,如果要代替的字符串无值(undefined)会报错




Mysql异常
CMake Error :The source directory "/usr/local/src/mysql-5.6.27" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.

//没有在 /usr/local/src/mysql-5.6.27目录下 找到 CMakeLists.txt 文件 5.6版本以上可能有些不一样,本人用的是5.5


com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column “title” row 1

//数据库字段长度不够,不一定是“title”,可能是同时插入的其他字段

<span style="color:#33ccff;">The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application </span>
*将jstl-1.2.jar复制到tomcat下面对应的lib中


Tomcat异常

项目部署时指向  项目路径错误

因某种因素。项目部署启动指向了早先启动的某个项目而非当前项目,需要确认路径是否正确

检查以下文件。。1、对应工作空间--项目中有个文件 .settings 下面 org.eclipse.wst.common.component 文件
将< wb-module deploy-name="wbg">  deploy-name 中的项目名改为对应的项目名称,如若其他地方名称不符也一并更改
2、同样在项目空间下  有个 .mymetadata 文件 将 context-root="/wbg"
 改为对应的项目名称路径 其他地方如若不同也一并更改
3、MyEclipse对应项目右击 Properties 选择 MyEclipse 中 Web 检查 Web Context-root(/wbgAdmin) 项目根路径是否正确
4、MyEclipse对应项目右击 Build Path -》 Configture Build Path -》 Java Build Path -》 Source 检查路径 wbgAdmin/WebRoot/WEB-INF/classes


MyEcplise异常

MyEcplise启动的时候一直卡在 Loading.org.eclipse.debug.core
在工作空间下,
一、找到.metadata\.plugins\org.eclipse.ui.workbench和.metadata\.plugins\org.eclipse.ui.workbench.texteditor然后删除

二、找到.metadata\.plugins\org.eclipse.core.resources下的 .snap 然后删除


打开MyEclipse
Could not create the view: An unexpected exception was thrown.
java.lang.NullPointerException
这个问题的出现是在启动MyEclipse之后出现的,这时还没有启动tomcat,因此可以排除tomcat中项目代码问题。
应该是myeclipse在初始化工作空间workspace 的时候出的问题。
仔细看下错误发现有一条at com.genuitec.eclipse.ast.deploy.core.Deployment.这个错误,
于是到 工作空间 下面的\Workspaces\.metadata\.plugins\org.eclipse.core.runtime\.settings目录下面
找到了名称为at com.genuitec.eclipse.ast.deploy的prefs文件,果断将此文件删除后重启


导入新的项目时,如果带 @Override 报错,可能是 jdk 版本错误

对项目右击--》Build Path--》configure Build Path--》java compiler--》更换JDK版本



java.lang.Exception: Socket bind failed: [730048] ?????????×???(Э?é/???????/???)????í?? 

原因:是端口已被占用.之前的tomcat进程没有被完全关闭掉.

避免方法:首先关闭tomcat再修改配置文件

解决方法:任务管理器或者kill杀死javaw进程重启tomcat即可.




DAOUtil 生成实体类成功,可数据没生成,查看工作空间下项目下是否生成calsses文件夹 如果生成src说明检出时,项目路径错误
项目右击查看properties -》java Build Path -》Source -》

查看default output folder:是否为 XXX/WebRoot/WEB-INF/classes  不是则说明检出路径错误,并重新检出更改


Mybatis异常

Mybatis在插入数据后,可通过Map获取插入数据ID,获取方式是map.get("id").toString();不可使用强制转换(String)map.get("id");

Could not find parameter map java.util.Map 错误
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.xml.IncompleteStatementException: Could not find parameter map java.util.Map
</pre><pre code_snippet_id="1567179" snippet_file_name="blog_20160127_3_6505104" class="line mt-5 q-content" name="code" style="white-space: pre-wrap; word-wrap: break-word; font-size: 14px; margin-top: 8px; margin-bottom: 0px; padding: 0px; font-family: arial, 'courier new', courier, 宋体, monospace, 'Microsoft YaHei'; word-break: break-all; line-height: 20px; background-color: rgb(255, 255, 255);">Could not find parameter map java.util.Map 的原因是Mybits 不支持 parameterMap
重点:就算当前执行语句是parameterType 但其他未执行中有写成 parameterMap 便依旧会报这个错误,
解决:MyEclipse 点击项目 - 选取菜单栏 Search - 选中Search ( 或者Ctrl +H )打开搜索界面,在搜索界面菜单栏里找到 File Search 输入 parameterMap 进行全文搜索,找到后更改成 parameterType  便可错误如下:执行第一条SQL 但依旧会报错,因为第二条未执行SQL中属性 parameterMap 存在

com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column “title” row 1 //数据库字段长度不够,不一定是“title”,可能是同时插入的其他字段
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值