<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. 3個存在同名屬性也存在不同名屬性的實體類** ```java @Data public class Address { private Integer stuId; private String address; } @Data public class Score { private Integer stuId; private Double score; } @Data public class StudentDto { private Integer stuId; private String address; private Double score; } ``` **2. 映射接口** ```java @Mapper public interface StudentMapper { StudentMapper INSTANCE = Mappers.getMapper(StudentMapper.class); /** * 1)當source1與source2不存在同名的屬性時可以進行自動映射。 * 2)當source1與source2存在同名的屬性時則需要明確指定是哪個source。 */ @Mapping(source = "source1.stuId", target = "stuId") StudentDto toDto(Address source1, Score source2); } ``` **3. 測試** ```java @Test public void testStudentMapper() { Address address = new Address(); Score score = new Score(); address.setStuId(1001); address.setAddress("亞洲-中國"); score.setStuId(1002); score.setScore(65.5d); StudentDto studentDto = StudentMapper.INSTANCE.toDto(address, score); //Address:Address(stuId=1001, address=亞洲-中國) System.out.println("Address:" + address); //Score:Score(stuId=1002, score=65.5) System.out.println("Score:" + score); //StudentDto:StudentDto(stuId=1001, address=亞洲-中國, score=65.5) System.out.println("StudentDto:" + studentDto); } ``` **4. 查看映射接口被Mapstruct編譯后的代碼** ```java public class StudentMapperImpl implements StudentMapper { public StudentMapperImpl() { } public StudentDto toDto(Address source1, Score source2) { if (source1 == null && source2 == null) { return null; } else { StudentDto studentDto = new StudentDto(); if (source1 != null) { studentDto.setStuId(source1.getStuId()); studentDto.setAddress(source1.getAddress()); } if (source2 != null) { studentDto.setScore(source2.getScore()); } return studentDto; } } } ```
                  <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>

                              哎呀哎呀视频在线观看