springboot整合ssm加mysql 测试阶段出现的问题及解决方法

1、Field userMapper in com.example.activitdemo.serviceImpl.UserServiceInpl required a bean of type 'com.example.activitdemo.dao.UserMapper' that could not be found.

在启动类 XXXXApplication 上加上注解 @MapperScan("com.example.activitdemo.dao"),或在mapper类上加上 @Mapper() 

2、org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'xxxxController' ..... Cause: org.apache.ibatis.builder.BuilderException: Mapper's namespace cannot be empty

  xxxMapper.xml中没有指定namespace 在<mapper>标签中加上 namespace="xx.xx.xx.xx.UserMapper"

3、Parameter 'userid' not found. Available parameters are [arg1, arg0, param1, param2]

这样写  X:

public interface UserMapper {
    TBEmp1 getUser(String name, String password);
}

这样写  √: 注意导入的包

import org.apache.ibatis.annotations.Param;

public interface UserMapper {
    TBEmp1 getUser(@Param("name") String name,@Param("password") String password);
}

4、确定好mysql的版本再引入依赖和配置数据库链接驱动,确定mysql服务开启了再测试连接

    mysql 5.0版本 :

        <!--MySQL数据库配置-->                                                                            #数据库链接驱动
        <dependency>                                                                                            driver-class-name: com.mysql.jdbc.Driver
            <groupId>mysql</groupId> 
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.41</version>
            <scope>runtime</scope>
        </dependency>

   mysql 8.0 版本: 

<!--MySQL数据库配置-->                                                  #数据库连接驱动
<dependency>                                                           driver-class-name: com.mysql.cj.jdbc.Driver                                                            
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.15</version>
</dependency>

 

#url  粘贴复制记得修改成自己的ip、端口和数据库 当我花一小时查出来是这个问题时死的心都有了
url: jdbc:mysql://192.168.206.220:3306/activiti?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT   mysql8.0版本的url完全版
url: jdbc:mysql://192.168.206.220:3306/activiti?serverTimezone=UTC  mysql8.0版本的url简洁版
url: jdbc:mysql://192.168.206.220:3306/activiti   mysql5.0版本

以上三部分无误可以避免以下问题:

com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure;

com.mysql.cj.exceptions.WrongArgumentException: Malformed database URL, failed to parse the ...

Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value 'xxx' is unrecognized or represents more than one time zone

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值