发布时间:2024-02-21 15:30
<build>
<resources>
<resource>
<directory>src/main/javadirectory>
<includes>
<include>**/*.xmlinclude>
includes>
resource>
resources>
build>
<dependency>
<groupId>com.baomidougroupId>
<artifactId>mybatis-plus-boot-starterartifactId>
<version>3.1.0version>
dependency>
mybatis-plus.mapper-locations=classpath:/mapper/*.xml
<dependency>
<groupId>com.baomidougroupId>
<artifactId>mybatis-plus-boot-starterartifactId>
<version>3.1.0version>
dependency>
mybatis.mapper-locations=classpath:mapper/*.xml
<select id="getPerson" resultType="com.b505.entity.Person">
select id, first_name firstName, last_name lastName, age, email, address from person where id = #{id}
select>
public interface PersonMapper
{
Map<String, Object> getPersonMap(Integer id);
}
<select id="getPersonMap" resultType="map">
select id, first_name firstName, last_name lastName, age, email, address from person where id = #{id}
select>
这种情况一般是使用主键(id)作为map的key,使用实体类作为value
public interface PersonMapper
{
@MapKey("id")
Map<Integer, Person> getPersonsMap(String address);
}
<select id="getPersonsMap" resultType="map">
select id, first_name firstName, last_name lastName, age, email, address from person where address = #{address}
select>