Postman 在我使用 Project lombok 时没有显示原始的 RestApi 响应



我使用通用的java样板来创建实体,它正确返回所有值。但是,在龙目岛项目的情况下,它不会返回响应。我正在分享代码。请指导我解决问题。

@Data
@NoArgsConstructor
@Entity(name="Designation")
public class Designation {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int Id;

private String Designation;

private float Salary;
}

构造函数如下所示:

@RestController
@RequestMapping("/desig")
public class DesignationController {
private DesignationService designationService;
@Autowired
public DesignationController(DesignationService designationService) {
this.designationService = designationService;
}

@GetMapping("/designation")
public List<Designation> getAllDesignation(){
return designationService.findAllDesignation();
}
}

服务:

@Service
public class DesignationServiceImpl implements DesignationService {
private DesignationRepository designationRepository;
@Autowired
public DesignationServiceImpl(DesignationRepository designationRepository) {
this.designationRepository = designationRepository;
}
@Override
public List<Designation> findAllDesignation() {
return designationRepository.findAll();
}
}

存储 库:

public interface DesignationRepository extends JpaRepository<Designation, Integer>{

}

邮递员回应:

[
{},
{},
{},
{},
{}
]

在 eclipse 控制台上使用调试器的响应,

2020-06-30 18:45:30.227 TRACE 11772 --- [nio-8080-exec-1] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([id1_0_] : [INTEGER]) - [1]
2020-06-30 18:45:30.227 TRACE 11772 --- [nio-8080-exec-1] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([designat2_0_] : [VARCHAR]) - [A]
2020-06-30 18:45:30.227 TRACE 11772 --- [nio-8080-exec-1] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([salary3_0_] : [FLOAT]) - [50000.0]
2020-06-30 18:45:30.227 TRACE 11772 --- [nio-8080-exec-1] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([id1_0_] : [INTEGER]) - [2]
2020-06-30 18:45:30.227 TRACE 11772 --- [nio-8080-exec-1] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([designat2_0_] : [VARCHAR]) - [B]
2020-06-30 18:45:30.227 TRACE 11772 --- [nio-8080-exec-1] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([salary3_0_] : [FLOAT]) - [45000.0]
2020-06-30 18:45:30.227 TRACE 11772 --- [nio-8080-exec-1] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([id1_0_] : [INTEGER]) - [3]
2020-06-30 18:45:30.228 TRACE 11772 --- [nio-8080-exec-1] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([designat2_0_] : [VARCHAR]) - [C]
2020-06-30 18:45:30.228 TRACE 11772 --- [nio-8080-exec-1] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([salary3_0_] : [FLOAT]) - [40000.0]
2020-06-30 18:45:30.228 TRACE 11772 --- [nio-8080-exec-1] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([id1_0_] : [INTEGER]) - [4]
2020-06-30 18:45:30.228 TRACE 11772 --- [nio-8080-exec-1] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([designat2_0_] : [VARCHAR]) - [D]
2020-06-30 18:45:30.228 TRACE 11772 --- [nio-8080-exec-1] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([salary3_0_] : [FLOAT]) - [35000.0]
2020-06-30 18:45:30.228 TRACE 11772 --- [nio-8080-exec-1] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([id1_0_] : [INTEGER]) - [5]
2020-06-30 18:45:30.228 TRACE 11772 --- [nio-8080-exec-1] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([designat2_0_] : [VARCHAR]) - [DFD]
2020-06-30 18:45:30.228 TRACE 11772 --- [nio-8080-exec-1] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([salary3_0_] : [FLOAT]) - [35000.0]

这里的任何人都可以告诉我为什么邮递员没有响应,因为我可以在 eclipse 控制台上获取数据。

在 Controll 中打印您的指定列表以查看值是否设置正确。

@RestController
@RequestMapping("/desig")
@Slf4j
public class DesignationController {
private DesignationService designationService;
@Autowired
public DesignationController(DesignationService designationService) {
this.designationService = designationService;
}

@GetMapping("/designation")
public List<Designation> getAllDesignation(){
List<Designation> designationList = designationService.findAllDesignation();
log.info("designationList = {}", designationList);
}
}

最新更新