记录学习java过程中遇到的各种问题

一起学习…

记录一:

整合SSM过程中,测试springmvc和spring整合情况时,启动tomcat运行,发现报404错误(The origin server did not find a current representation for the target resource or is not willing to),日志没有报错,但是打印(No mapping found for HTTP request with URI [/xp_ssm_519_01_war/] in Dispatch)

原因及解决办法:
原因在于重写index.jsp文件时,把原index.jsp文件删掉了重新建立了一个新的index.jsp,建立时的位置不小心建错了,本应该建立在webapp目录下,结果建立在了WEB-INF目录下,因此导致出错。

记录二:

整合SSM过程中,整合spring和springmvc后没问题,后来整合spring和mybatis时报错
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘accountService’: Unsatisfied dependency expressed through field ‘iAccountDao’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.xp.Dao.IAccountDao’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:586)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:372)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1344)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
19-May-2019 23:47:40.863 涓ラ噸 [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)

原因及解决方法:

applicationContext.xml因为时复制粘贴过来的,有些地方的全限定类名错误,忘记修改,导致出现这一错误。比如原来正常的应该是value=com.xp.Dao,错误的却是value=com.xp.ssm.Dao

记录三

jsp页面 ${变量名}没有替换成真实的数值,直接显示了${变量名}

原因及解决方法

jsp 页面<%@ page contentType=“text/html;charset=UTF-8” language=“java” %>
这句末尾一定要加上 isELIgnored=“false” ,所以正确写法
<%@ page contentType=“text/html;charset=UTF-8” language=“java” isELIgnored=“false” %>

**

记录四

**
在这里插入图片描述

springboot整合mybatis时,在application.properties中配置driver-class-name时报红字错误

原因及解决方法
配置pom.xml文件时,添加mysql-connector-java 的verion,并且值为8.0.11或8.0.14
<version>8.0.11</version><version>8.0.14</version>暂时只发现这两个版本合适。

**

记录五

**
在这里插入图片描述
Controller层,@Authorized Dao层的接口时,报红字下划线
Could not autowire. No beans of ‘AccountDao’ type found. less… (Ctrl+F1)
Inspection info:Checks autowiring problems in a bean class.

记录六

如果是配置了国内镜像,并且镜像文件为/etc/docker/daemon.json,则修改文件后缀为.conf即可正常启动docker 服务

原因及解决方法
无影响,idea的自身问题

记录七

sql语句没毛病,但是报错或者mybtis映射字段一致,却查出字段为空

原因及解决方法
tab,考虑制表符的影响,有些看不见的空格可能就是制表符

记录八

springcloud feign学习时,报错 “status 405 reading FeignInterface#xp(String)”,
并没有报get和post的错,服务接口和feign client接口都是get请求且输入一个参数。

原因及解决方法
在feign client接口中加上注解@RequestParam

记录九

解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)错误

原因及解决方法
service层没加@Service注解
dao层没加@Repository注解
mapperScan设置扫描包的范围没有包含dao,service层
或者其他注解需要扫包的也没有包含扫到报错所指的类的所在包

记录十

java.util.ConcurrentModificationException: null
原因及解决方法
原因是在遍历list的过程中,如果修改了元素,会导致list中索引与对应的值不同,因此抛出异常;

使用.remove()方法,不使用.remove(object)方法,非要使用这种方法的话用Iterator iter=null; iter = criteria3.iterator();迭代器的方法。

记录十一

SimpleDateFormat dateFormat = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”);
时间和系统时间相差12小时,HH:mm:ss中的HH应该大写而不是小写
持续更新中

记录十二

mybatis mapper-locations作用
application上配置了@MapperScan(扫面mapper类的路径)和pom.xml中放行了mapper.xml后,配置mapper-locations没有意义

查找后得知,如果mapper类和mapper.xml不在同一个路径下时,mapper-locations就有用了,在pom.xml中配置

mybatis.mapper-locations=classpath*:com/example/demo/mapper/*.xml
用mapper-locations指定mapper.xml的路径,实验成功

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值