MyBatis 无法在查询中设置参数

MyBatis can't set arguments on query

Mybatis 报错说参数设置有问题。有什么问题吗?我测试了 SQL 查询,没问题。我在 spring.

中使用 gradle

Error querying database.
Cause: org.postgresql.util.PSQLException: ERROR: syntax error at or near "customer" Position: 245
The error may exist in services/CustomerService.java (best guess)
The error may involve services.CustomerService.findByPersonalCodeAndCountry-Inline
The error occurred while setting parameters

代码:

import com.luminor.dc.ccc.contracts.dao.Customer;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
@Mapper
public interface CustomerService {


    @Select("Select * FROM customer WHERE cust_personal_code= #{personalCode} AND cust_bank_country = #{country}")
    List<Customer> findByPersonalCodeAndCountry(@Param("personalCode") String personalCode,@Param("country") String country);
}

控制器

@RestController
@RequestMapping(value = "/v1/customers", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class CustomerController {

   private CustomerService customerService;

    public CustomerController(@Autowired CustomerService customerService) {
        this.customerService = customerService;
    }

    @GetMapping("/{personalCode}")
    public List<Customer> getCustomersByPersonalCode(@PathVariable String personalCode, @RequestHeader String country) {
        return customerService.findByPersonalCodeAndCountry(personalCode, country);
    }
}

Table

你能试试下面的代码吗?

Controller method :
     @GetMapping("/{personalCode}")
        public List<Customer> getCustomersByPersonalCode(@PathVariable String personalCode, @RequestHeader(value="country") String country) {
            return customerService.findByPersonalCodeAndCountry(personalCode, country);
        }

@Results(value = { @Result(column = "id", property = "id"), 
        @Result(column = "cust_personal_code", property = "personalCode"), 
        @Result(column = "cust_bank_country ", property = "country")
    )}
    @Select("Select * FROM customer WHERE cust_personal_code= #{personalCode} AND cust_bank_country = #{country}")
    List<Customer> findByPersonalCodeAndCountry(@Param("personalCode") String personalCode, @Param("country") String country);

where id, personalCode,country : variables in customer POJO Table-> id(Integer),cust_personal_code (String ),cust_bank_country(String ) : columns in table