记录-项目java项目框架搭建的一些问题(maven+spring+springmvc+mybatis)

伴随着项目框架的落成后,本以为启动就能成功的,but。。。。

项目启动开始报错误1:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

这个错百度到说是缺少这个包,但实际在项目中看到maven里面是有这个包的。于是继续百度到【可能包是找到了,但没有依赖在项目中】

项目右击-----project-----deployment assembly , add ,java build path entries , Maven Dependencies . 将他添加进来

【这样才能在发布时,将maven的jar包一起放到服务器中.】:原文如下

问题解决了.. 
方案: 

project 右键, deployment assembly , add ,java build path entries , Maven Dependencies . 

这样才能在发布时,将maven的jar包一起放到服务器中.
多谢分享, 我也遇到了这个问题, 我这边的情况是:用maven 添加spring mvc jar包后,工程中没有被引用到这些jar,问题有两个地方: 
1. 工程名上右击 -> maven 中没有操作update project; 
2. 工程名上右击 -> Properties -> Deployment Assembly,右边框中没有操作如下步骤: 
   Add -> Java Build Path Entries -> next -> 选择maven Dependencies; 

通过上面操作后还是有点小问题,虽然spring jar在工程有被引用进来了,但是代码中无法引用类库,于是操作如下即可: 
1. 工程名上右击 -> maven -> Disable Maven Nature; 
2. 工程名上右击 -> Configure -> Convert to maven project; 
3. 最后需再次检查最上面描述两个问题的地方是否有重现,如有,重复步骤;

  

访问数据报错:
Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Communications link failure

1.确定服务是启着的
 2.确定网络没问题.
3.其他软件没把oracle的端口占用,或配置文件里端口号没有写错。
4.把服务器的防火墙关了,再试一下。
5.是不是你数据库设置了最大连接,然后其他项目的连接池又把连接占用完了呢。


过滤了以上的情况我的错误原因是:
url=jdbc:mysql://localhost:8080/said?useUnicode=true&characterEncoding=gbk

8080改成3306,也就是数据库的链接熟悉端口号错误,还是怪自己大意
 项目启动成功业务实现时报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

 解决方法

把mybatis的Mapper.java 和 Mapper.xml 和Mapper.xml中得,namespace 保持一致,
简单的说: 把Mapper.java 和Mapper.xml放入到同一个包中,然后XML中得namespace=Mapper.java的全类名 就 OK了

 项目启动成功业务实现时报错:java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

 解决方法:

我的情况是:在jdbc.properies文件里面的是“driver=com.mysql.jdbc.Driver      ”多了个空格。

  

 项目启动成功业务实现时报错:java.sql.SQLException: null,  message from server: "Host 'webc-PC' is not allowed to connect to this MySQL server"

  解决方法:(我的环境是自己的电脑的项目、自己电脑上的数据库)

这个问题百度了很多都是说没权限访问数据库、数据库链接信息不正确等
方案一:改表
use mysql ;select user,host,password from user;
update user set host = '%' where user='root';

按照上面的方法,在mysql指令窗口中并没有实现。但在可视化 窗口下查看mysql数据库下的user中有一个链接地址:127.0.0.1   随后在项目的jdbc配置文件中将地址修改为 127.0.0.1后,项目启动数据库得以访问~~

  

 org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'callerNbr' in 'class java.lang.String'

<select id="selectUserByPhone" resultType="com.fjt.callcenter.models.manage.User" parameterType="java.lang.String">
          select * from user where ifnull(Deleted,0)=0
          <if test="callerNbr !=null and callerNbr!=''">
              and PhoneNo=#{callerNbr}
          </if>
  </select>

将上面的if 标签去掉,原因是标签是针对JAVABEAN或者MAP的,STRING不能用标签,因为我上面传进来的是字符串类型
原文地址:https://www.cnblogs.com/dscs/p/5022721.html