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

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条回答 默认 最新

相关推荐 更多相似问题