肇事接口如下
/**
* get
* @param vin
* @return
*/
@RequestMapping(method = RequestMethod.GET, value = "/get")
TxxxGetDTO get(@RequestParam @NotBlank String vin);
代码本地启动没问题,但是jenkins发布到测试环境就启动报错
2023-06-12 15:24:05.612 ERROR --- [main] o.s.boot.SpringApplication : [] Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'TxxxBindController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com..xx.dms.services.integration.UxxxFacadeFegin': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: RequestParam.value() was empty on parameter 0
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:321)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1422)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
解决方法
RequestParam 注解后面加上value,这个是Spring 4.0版本后,@RequestParam 注解对参数传值有了很好的封装特性并严格校验。
/**
* get
* @param vin
* @return
*/
@RequestMapping(method = RequestMethod.GET, value = "/get")
TxxxGetDTO get(@RequestParam(value = "vin") @NotBlank String vin);