1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 项目开发中常见报错解决方法【eclipse】

项目开发中常见报错解决方法【eclipse】

时间:2024-03-14 15:07:18

相关推荐

项目开发中常见报错解决方法【eclipse】

项目运行中报错处理

开发工具1. 报 Error starting ApplicationContext. To display the auto-configuration report re-runyour application错误;2. 连接远程数据出现1045错误;3. 报Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 77; 必须声明元素类型 "resultmap";4. 报HTTP Status 500 - An exception occurred processing JSP page /web-INF/***/*.jsp at line 56;5. 报HTTP Status 500 - Request processing failed; nested exception is java.lang.IllegalStateException: Optional int parameter 'currentPage' is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type.6. 报java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp;7. 报HTTP Status 500 - Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Mapper method 'com.homemarket.system.dao.AppraiseMapper.deleteUserAppraise' has an unsupported return type: interface java.util.List;8. 报java.lang.NumberFormatException: For input string: "appPrName";9. 报javax.servlet.ServletException: Servlet.init() for servlet dispatcherServlet threw exception;10. 报HTTP Status 500 - org.springframework.beans.BeanInstantiationException.....11. 当导入的js文件报错;12. 当主页面执行功能时,不能局部刷新新的页面时修改方法;13. HTTP Status 500 - org.mybatis.spring.MyBatisSystemException:nested exception is org.apache.ibatis.type.TypeException.....14. HTTP Status 500 - org.mybatis.spring.MyBatisSystemException:nested exception is org.apache.ibatis.exceptions;15. 通过在前端的单选按钮选中某一值添加到数据库中时,选中而没有添加进去;16. radio根据后台传的值进行性别选中;17. 端口占用问题;18. 依赖报错;.apache.maven.archiver.MavenArchiver.getManifest(org.apache.maven.project.MavenProject,org.apache.maven.archiver.MavenArchiveConfiguration);20.更新时,页面显示正常,但是数据库中没有更新;21. 遍历两个list集合的方法;22. 报java.lang.ArithmeticException: / by zero异常;23. 生成ssl证书;

开发工具

eclipse 4.5

1. 报 Error starting ApplicationContext. To display the auto-configuration report re-runyour application错误;

原因:application配置文件丢了!

2. 连接远程数据出现1045错误;

解决方法:

在MySQL中执行

grant all on *.* to 用户名@"%" identified by "密码";flush privileges;

然后重启服务即可。

注:用户名和密码是远程数据库的用户名和密码

3. 报Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 77; 必须声明元素类型 “resultmap”;

原因:<resultMap></resultMap>标签写错了。

4. 报HTTP Status 500 - An exception occurred processing JSP page /web-INF/**/.jsp at line 56;

解决方法:<c:forEach items="${appraiseList}" var=“goodAppraise”>

5. 报HTTP Status 500 - Request processing failed; nested exception is java.lang.IllegalStateException: Optional int parameter ‘currentPage’ is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type.

解决方法:把currentPage的类型改为Integer并且给参数加@RequestParam(value="currentPage",defaultValue="0")0指从第0+1条数据开始往后取rows条

把rows的类型改为Integer并且给参数加

@RequestParam(value="rows",defaultValue="5")5指默认每页有5条数据

例如:

public String deleteDoctor(Model model, Integer dId, @RequestParam(value="currentPage",defaultValue="0")Integer currentPage, @RequestParam(value="rows",defaultValue="5")Integer rows) {// 调用业务int a = doctorService.deleteDoctor(dId);System.err.println("=============="+a);// 准备数据List<Doctor> doctor_db = doctorService.queryAllDoctor();// 分页int TotalCount = doctor_db.size();int totalPage = TotalCount % rows == 0 ? TotalCount / rows : TotalCount / rows + 1;if (currentPage == 0) {currentPage = 1;}if (currentPage == totalPage + 1) {currentPage = totalPage;}int currentPage2 = (currentPage - 1) * rows;List<Doctor> doctors = doctorService.queryAllDoctorPage(currentPage2, rows);model.addAttribute("doctor_db", doctor_db);model.addAttribute("doctors", doctors);model.addAttribute("totalPage", totalPage);model.addAttribute("currentPage", currentPage);model.addAttribute("rows", rows);// 跳转页面return "view/manager/doctor/queryDoctor";}

注:此时在menu菜单中写入的地址为ManagerController/queryDoctor.do不用再在后面添加currentPage和rows

6. 报java.sql.SQLException: Value ‘0000-00-00 00:00:00’ can not be represented as java.sql.Timestamp;

原因分析:

因为“0000-00-00 00:00:00”在mysql中是作为一个特殊值存在的但 java.sql.Date 将其视为 不合法的值 格式不正确,这才是报错的原因;

解决方法:

(1)给jdbc url加上zeroDateTimeBehavior参数:

zeroDateTimeBehavior=round是为了指定MySql中的DateTime字段默认值查询时的处理方式;

默认是抛出异常jdbc.url=jdbc:mysql://localhost:3306/tms?zeroDateTimeBehavior=convertToNull

(2)把数据库中0000-00-00 00:00:00的时间删除。

7. 报HTTP Status 500 - Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Mapper method ‘com.homemarket.system.dao.AppraiseMapper.deleteUserAppraise’ has an unsupported return type: interface java.util.List;

解决方法:定义的函数返回类型改为int类型的。

8. 报java.lang.NumberFormatException: For input string: “appPrName”;

解决方法:需要加forEach遍历

9. 报javax.servlet.ServletException: Servlet.init() for servlet dispatcherServlet threw exception;

解决方法:dao层的定义为接口,错误定义为class类了

10. 报HTTP Status 500 - org.springframework.beans.BeanInstantiationException…

解决方法:controller层中的HttpSession session 的包导错了,正确为import javax.servlet.http.HttpSession;

11. 当导入的js文件报错;

(1)可以直接右击鼠标选择validate即可解决;

(2)在window->preferences->web->javaServer->validate->general中修改。

12. 当主页面执行功能时,不能局部刷新新的页面时修改方法;

13. HTTP Status 500 - org.mybatis.spring.MyBatisSystemException:nested exception is org.apache.ibatis.type.TypeException…

(1)

解决方法:

(2)

报错原因分析:数据库中设置的数据类型是int,而在前端输入的时候用的是string ,设置数据类型一致即可。

14. HTTP Status 500 - org.mybatis.spring.MyBatisSystemException:nested exception is org.apache.ibatis.exceptions;

原因:所查的表中存在相同的两条数据。删除其中一条,可以解决。

15. 通过在前端的单选按钮选中某一值添加到数据库中时,选中而没有添加进去;

解决方法:

在前端的语句中加入value值即可。value表示加入数据库中的值

16. radio根据后台传的值进行性别选中;

17. 端口占用问题;

(1)

(2) 配置ssl证书后,启动项目报443端口被占用了

(3)代理抛出异常错误: java.rmi.server.ExportException: Port already in use: 32803; nested exception is:

.BindException: Address already in use: JVM_Bind

解决方法:

暴力:找到占用的端口号,并且找到对应的进程,杀死该进程(三种情况都适用)

netstat -ano | findstr 端口号 taskkill -PID 进程号 -F

温柔:修改自身的端口号 conf/server.xml(适用于第一种占用)

* 一般会将tomcat的默认端口号修改为80。80端口号是http协议的默认端口号。

* 好处:在访问时,就不用输入端口号

18. 依赖报错;

解决方法:将本地库里面这个依赖对应的文件夹删掉,然后在eclipse里面执行update dependencies。成功解决问题!

右键单击项目->maven->update dependencies。

.apache.maven.archiver.MavenArchiver.getManifest(org.apache.maven.project.MavenProject,org.apache.maven.archiver.MavenArchiveConfiguration);

解决方法:pom文件中maven-jar-plugin的版本过高,改版本在2.6或者2.6以下。并更新maven。

<properties><java.version>1.8</java.version><maven-jar-plugin.version>2.4</maven-jar-plugin.version></properties>

20.更新时,页面显示正常,但是数据库中没有更新;

错误代码:

正确代码:

21. 遍历两个list集合的方法;

其中medicalsappointments分别是从后台传递过来的两个集合。

22. 报java.lang.ArithmeticException: / by zero异常;

错误指向int totalPage = TotalCount % rows == 0 ? TotalCount / rows : TotalCount / rows + 1;代码。

分析错误原因:rows=0,导致报错

解决方法:

23. 生成ssl证书;

在B/S中ssl是使用https协议来实现的,可以在jdk安装目录bin目录下(D:\Program Files\Java\jdk1.8.0_91\bin>)输入以下命令生成。

keytool -genkey -alias tomcat

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。