ssm请求服务器,服务器报其中一条写Result Maps集合已经包含了com.duing.dao.PlayMapper.BaseResultMap的值,怀疑是mybatis generator工具生成文件的问题,有遇到过这种问题的吗
代码太多到达上限了,只能上传一部分
报错信息
controller信息
package com.duing.controller;
import com.duing.service.FilmService;
import com.duing.vo.FilmDetailVo;
import com.duing.vo.FilmVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
@Controller
public class FilmController {
@Autowired
private FilmService filmService;
@RequestMapping("/filmList")
@ResponseBody
public List<FilmVo> selectAll(){
List<FilmVo> filmVos = filmService.selectAll();
return filmVos;
}
@RequestMapping("/home")
public String home(Model model){
System.out.println("接受首页请求");
List<FilmVo> filmVoList = filmService.selectAll();
model.addAttribute("filmVoList",filmVoList);
return "home";
}
// 接受请求参数
@RequestMapping("/filmInfo")
public String filmInfo(@RequestParam String filmId, Model model){
FilmDetailVo detailVo=filmService.findFilmById(filmId);
model.addAttribute("detailVo",detailVo);
return "detail";
}
}
package com.duing.controller;
import com.duing.service.PlayService;
import com.duing.vo.PlayVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
@Controller
public class PlayController {
@Autowired
private PlayService playService;
@RequestMapping("play")
@ResponseBody
public List<PlayVo> getplays(@RequestParam String filmId){
List<PlayVo> result = playService.fndPlayById(filmId);
return result;
}
}
dao层
package com.duing.controller;
import com.duing.service.PlayService;
import com.duing.vo.PlayVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
@Controller
public class PlayController {
@Autowired
private PlayService playService;
@RequestMapping("play")
@ResponseBody
public List<PlayVo> getplays(@RequestParam String filmId){
List<PlayVo> result = playService.fndPlayById(filmId);
return result;
}
}
package com.duing.dao;
import com.duing.entity.Play;
import com.duing.entity.PlayExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface PlayMapper {
long countByExample(PlayExample example);
int deleteByExample(PlayExample example);
int deleteByPrimaryKey(Long id);
int insert(Play record);
int insertSelective(Play record);
List<Play> selectByExample(PlayExample example);
Play selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") Play record, @Param("example") PlayExample example);
int updateByExample(@Param("record") Play record, @Param("example") PlayExample example);
int updateByPrimaryKeySelective(Play record);
int updateByPrimaryKey(Play record);
List<Play> selectAll();
List<Play> selectByFilmId(String filmId);
}
package com.duing.dao;
import com.duing.entity.Room;
import com.duing.entity.RoomExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface RoomMapper {
long countByExample(RoomExample example);
int deleteByExample(RoomExample example);
int deleteByPrimaryKey(Long id);
int insert(Room record);
int insertSelective(Room record);
List<Room> selectByExample(RoomExample example);
Room selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") Room record, @Param("example") RoomExample example);
int updateByExample(@Param("record") Room record, @Param("example") RoomExample example);
int updateByPrimaryKeySelective(Room record);
int updateByPrimaryKey(Room record);
}
domain实体
package com.duing.entity;
import java.io.Serializable;
import java.util.Date;
// 实体类 跟数据库的表映射
public class Film implements Serializable {
private static final long serialVersionUID = -4427069375523038931L;
private long id;
private String film_id;
private String name;
private String director;
private String player;
private String type;
private String country;
private int length;
private String synopsis;
private Date play_time;
private String img_path;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getFilm_id() {
return film_id;
}
public void setFilm_id(String film_id) {
this.film_id = film_id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDirector() {
return director;
}
public void setDirector(String director) {
this.director = director;
}
public String getPlayer() {
return player;
}
public void setPlayer(String player) {
this.player = player;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public int getLength() {
return length;
}
public void setLength(int length) {
this.length = length;
}
public String getSynopsis() {
return synopsis;
}
public void setSynopsis(String synopsis) {
this.synopsis = synopsis;
}
public Date getPlay_time() {
return play_time;
}
public void setPlay_time(Date play_time) {
this.play_time = play_time;
}
public String getImg_path() {
return img_path;
}
public void setImg_path(String img_path) {
this.img_path = img_path;
}
}
package com.duing.entity;
import java.util.Date;
public class Play {
private Long id;
private String playId;
private Date playTime;
private String lanType;
private Long price;
private String roomId;
private String roomName;
private String filmId;
private String filmName;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getPlayId() {
return playId;
}
public void setPlayId(String playId) {
this.playId = playId;
}
public Date getPlayTime() {
return playTime;
}
public void setPlayTime(Date playTime) {
this.playTime = playTime;
}
public String getLanType() {
return lanType;
}
public void setLanType(String lanType) {
this.lanType = lanType;
}
public Long getPrice() {
return price;
}
public void setPrice(Long price) {
this.price = price;
}
public String getRoomId() {
return roomId;
}
public void setRoomId(String roomId) {
this.roomId = roomId;
}
public String getRoomName() {
return roomName;
}
public void setRoomName(String roomName) {
this.roomName = roomName;
}
public String getFilmId() {
return filmId;
}
public void setFilmId(String filmId) {
this.filmId = filmId;
}
public String getFilmName() {
return filmName;
}
public void setFilmName(String filmName) {
this.filmName = filmName;
}
}
service层
package com.duing.service;
import com.duing.vo.FilmDetailVo;
import com.duing.vo.FilmVo;
import java.util.List;
public interface FilmService {
List<FilmVo> selectAll();
FilmDetailVo findFilmById(String filmId);
}
package com.duing.service;
import com.duing.entity.Film;
import com.duing.vo.PlayVo;
import java.util.List;
public interface PlayService {
List<PlayVo> fndPlayById(String filmId);
}
service接口
package com.duing.service;
import com.duing.vo.FilmDetailVo;
import com.duing.vo.FilmVo;
import java.util.List;
public interface FilmService {
List<FilmVo> selectAll();
FilmDetailVo findFilmById(String filmId);
}
package com.duing.service;
import com.duing.entity.Film;
import com.duing.vo.PlayVo;
import java.util.List;
public interface PlayService {
List<PlayVo> fndPlayById(String filmId);
}
util工具
package com.duing.util;
import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.config.xml.ConfigurationParser;
import org.mybatis.generator.internal.DefaultShellCallback;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class GeneratorUtil {
public static void main(String[] args) throws Exception{
// 执行过程中的报警信息
List<String> warnings = new ArrayList<String>();
// 当代码重复是否覆盖
boolean overwrite = true;
File configFile = new File("D:\\ssm-duing-ticket\\ssm-duing-ticket\\mybatis\\generatorConfig.xml");
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = cp.parseConfiguration(configFile);
DefaultShellCallback callback = new DefaultShellCallback(overwrite);
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
myBatisGenerator.generate(null);
for (String warning : warnings) {
System.out.println(warning);
}
}
}
mybatis generator工具的配置
<!DOCTYPE generatorConfiguration PUBLIC
"-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<context id="simple" targetRuntime="MyBatis3">
<property name="javaFileEncoding" value="UTF-8"/>
<commentGenerator>
<property name="suppressDate" value="true"/>
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/ssm"
userId="root" password="root"/>
<javaModelGenerator targetPackage="com.duing.entity" targetProject="D:\ssm-duing-ticket\ssm-duing-ticket\src\main\java"/>
<sqlMapGenerator targetPackage="mappers" targetProject="D:\ssm-duing-ticket\ssm-duing-ticket\src\main\resources"/>
<javaClientGenerator type="XMLMAPPER" targetPackage="com.duing.dao" targetProject="D:\ssm-duing-ticket\ssm-duing-ticket\src\main\java"/>
<table tableName="play" />
</context>
</generatorConfiguration>
vo展示层
package com.duing.vo;
import java.util.Date;
public class FilmDetailVo {
private String filmId;
private String name;
private String director;
private String player;
private String type;
private String country;
private int length;
private String synopsis;
private Date playTime;
private String imgPath;
public String getFilmId() {
return filmId;
}
public void setFilmId(String filmId) {
this.filmId = filmId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDirector() {
return director;
}
public void setDirector(String director) {
this.director = director;
}
public String getPlayer() {
return player;
}
public void setPlayer(String player) {
this.player = player;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public int getLength() {
return length;
}
public void setLength(int length) {
this.length = length;
}
public String getSynopsis() {
return synopsis;
}
public void setSynopsis(String synopsis) {
this.synopsis = synopsis;
}
public Date getPlayTime() {
return playTime;
}
public void setPlayTime(Date playTime) {
this.playTime = playTime;
}
public String getImgPath() {
return imgPath;
}
public void setImgPath(String imgPath) {
this.imgPath = imgPath;
}
}
package com.duing.vo;
// 视图层对象 用来展示给用户使用
public class FilmVo {
private String filmId;
private String name;
private String director;
private String imgPath;
public String getFilmId() {
return filmId;
}
public void setFilmId(String filmId) {
this.filmId = filmId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDirector() {
return director;
}
public void setDirector(String director) {
this.director = director;
}
public String getImgPath() {
return imgPath;
}
public void setImgPath(String imgpath) {
this.imgPath = imgpath;
}
}
package com.duing.vo;
import java.util.Date;
public class PlayVo {
private Long id;
private String playId;
private Date playTime;
private String lanType;
private Long price;
private String roomId;
private String roomName;
private String filmId;
private String filmName;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getPlayId() {
return playId;
}
public void setPlayId(String playId) {
this.playId = playId;
}
public Date getPlayTime() {
return playTime;
}
public void setPlayTime(Date playTime) {
this.playTime = playTime;
}
public String getLanType() {
return lanType;
}
public void setLanType(String lanType) {
this.lanType = lanType;
}
public Long getPrice() {
return price;
}
public void setPrice(Long price) {
this.price = price;
}
public String getRoomId() {
return roomId;
}
public void setRoomId(String roomId) {
this.roomId = roomId;
}
public String getRoomName() {
return roomName;
}
public void setRoomName(String roomName) {
this.roomName = roomName;
}
public String getFilmId() {
return filmId;
}
public void setFilmId(String filmId) {
this.filmId = filmId;
}
public String getFilmName() {
return filmName;
}
public void setFilmName(String filmName) {
this.filmName = filmName;
}
}
mapper文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.duing.dao.FilmMapper">
<select id="getList" resultType="com.duing.entity.Film">
select id , film_id,`name`,director,player,`type`,country,`length`,synopsis,play_time,img_path
from film;
</select>
<select id="getFilmById" resultType="com.duing.entity.Film">
select id , film_id,`name`,director,player,`type`,country,`length`,synopsis,play_time,img_path
from film
where film_id = #{filmId};
</select>