<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                **1. 兩個字段名不一致的實體類** ```java @Data public class Car { private Integer carId; private String carName; } @Data public class CarDto { private Integer carDtoId; private String carDtoName; } ``` **2. 映射接口** ```java @Mapper public interface CarMapper { CarMapper INSTANCE = Mappers.getMapper(CarMapper.class); /** * 使用@Mapping的source和target讓兩個實體類的屬性進行對應 */ @Mapping(source = "carId", target = "carDtoId") @Mapping(source = "carName", target = "carDtoName") CarDto toDto(Car source); } ``` **3. 測試** ```java @Test public void testCarMapper() { Car car = new Car(); car.setCarId(1001); car.setCarName("紅旗"); CarDto carDto = CarMapper.INSTANCE.toDto(car); //Car:Car(carId=1001, carName=紅旗) System.out.println("Car:" + car); //Car-->CarDto:CarDto(carDtoId=1001, carDtoName=紅旗) System.out.println("Car-->CarDto:" + carDto); } ``` **4. 查看映射接口被Mapstruct編譯后的代碼** ```java public class CarMapperImpl implements CarMapper { public CarMapperImpl() { } public CarDto toDto(Car source) { if (source == null) { return null; } else { CarDto carDto = new CarDto(); carDto.setCarDtoId(source.getCarId()); carDto.setCarDtoName(source.getCarName()); return carDto; } } } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看