public interface ProductInfoRepository extends JpaRepository<ProductInfo, String>{
    List<ProductInfo> findByProductId(String productId);
}

ProductInfoController

@Autowired
private ProductInfoRepository productInfoRepository;

@GetMapping("/ProductId/{id}")
public List<ProductInfo> findByProductId(@PathVariable("id")String productId){
    List<ProductInfo> productInfoList = productInfoRepository.findByProductId(productId);
    return productInfoList;
}

application.yml

spring:
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    username: root
    password: xzh456
    url: jdbc:mysql://localhost:3306/springcloud_sell?characterEncoding=utf-8&useSSL=false
  jpa:
    show-sql: true
11-17 17:30