报错代码如下:
@NonDS
@RestController
@AllArgsConstructor
public class OaToErpClient implements IOaToErpClient {
private final OaGetMapper oaGetMapper;
private final IK3CloudApiClient ik3CloudApiClient;
/**
* 接口平台connect-erp appKey
*/
@Value("${ipass.appKey.connector-erp}")
private String connectorErpAppKey;
//........
}
报错信息如下:
Description:
Parameter 2 of constructor in com.justech.erp.feign.OaToErpClient required a bean of type 'java.lang.String' that could not be found.
Action:
Consider defining a bean of type 'java.lang.String' in your configuration.
我的原因是由于参数所在类需要用到其他类的方法,所以引入依赖。用的是@AllArgsConstructor注解去生成构造器去匹配Bean的依赖,而这个构造器并不包含直接注入的String类型的参数。
因此更换为注解@RequiredArgsConstructor,只包含final和@NonNull字段的构造器。
@NonDS
@RestController
@RequiredArgsConstructor
public class OaToErpClient implements IOaToErpClient {
private final OaGetMapper oaGetMapper;
private final IK3CloudApiClient ik3CloudApiClient;
/**
* 接口平台connect-erp appKey
*/
@Value("${ipass.appKey.connector-erp}")
private String connectorErpAppKey;
//....
}