blueness_sunshine 2018-06-24 09:39 采纳率: 40%
浏览 2301
已采纳

spring-boot mybatis 查询mysql报错问题

 2018-06-24 17:32:23.171 ERROR 6371 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.lang.NullPointerException
### The error may exist in file [/Users/ww/IdeaProjects/test-Service/test-Search/target/classes/mapping/TestMapper.xml]
### The error may involve com.test.data.mapper.TestMapper.selectByPrimaryKey
### The error occurred while executing a query
### Cause: java.lang.NullPointerException] with root cause

java.lang.NullPointerException: null

我的pom.xml

  <!-- Spring Boot Mybatis-->
      <dependency>
        <groupId>org.mybatis.spring.boot</groupId>
        <artifactId>mybatis-spring-boot-starter</artifactId>
        <version>1.3.2</version>
      </dependency>

      <!-- 数据源 -->
      <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>druid</artifactId>
        <version>1.0.19</version>
      </dependency>
      <!-- MySQL-->
      <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.39</version>
      </dependency>

TestMapper.java代码

     TestConfig selectByPrimaryKey(Long id);

TestMapper.xml

  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
    select
    <include refid="Base_Column_List" />
    from test_config
    where id = #{id,jdbcType=BIGINT}
  </select>

请各位大神帮忙看一下,几乎所有查询都报这个错误,用了@Param 注释也不行

  • 写回答

7条回答 默认 最新

  • hot2dog 2018-06-25 01:46
    关注

    mapping/TestMapper.xml 、 com.test.data.mapper.TestMapper.selectByPrimaryKey 检查一下 所在包,感觉不在一个包下呢?

    搞不好 是没在一个包下, 扫描不到 这个命名空间的 selectByPrimaryKey 方法,也有可能哟。。。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(6条)

报告相同问题?

悬赏问题

  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler