项目是springBoot+MyBatis-Plus注释方式开发
/*** * 新增新闻 * @param news * @return */ @Insert("insert into zhxy_news (image,title,content) values (#{image},#{title},#{content})") Boolean insertNews(News news); /*** * 按id查询新闻 * @param id * @return */ @Select("select * from zhxy_news where id = #{id} and del_flag = 0") News selectNewsById(Integer id); /*** * 查询新闻列表 * @param * @return */ @Select("select * from zhxy_news where del_flag = 0") List<News> selectNews(); /*** * 修改新闻 * @param news * @return */ @Update("update zhxy_news set image=#{image},title=#{title},content=#{content} where id = #{id}") Boolean updateNews(News news); /*** * 逻辑删除新闻 * @param id * @return */ @Update("update from zhxy_news set del_flag = 1 where id = #{id}") Boolean delNews(Integer id);然后需要复杂查询的时候就需要xml了 最开始在访问的时候一直找不到方法,然后找问题,发现是有些东西忘记配置了 在项目的启动类中需要加注解
@MapperScan("com.skypegmwcn.zhxy.skypegmwcn.mapper")然后还是访问不了。。。再找是哪里的问题 发现是application.yml中路径配错了,最开始的是不知道在哪里复制的代码是mapping然后改成了mapper
mybatis: mapper-locations: classpath:/mapper/*.xml type-aliases-package: com.example.entity config-location: classpath:mybatis-config.xml 嗯正常访问了