我有一个如下所示的异常类
@ResponseStatus(value=HttpStatus.UNPROCESSABLE_ENTITY, reason="Unprocessable Entity") // 422
public class UnprocessableEntityException extends RuntimeException {
}
Run Code Online (Sandbox Code Playgroud)
现在状态不会返回为 422,除非我在 Controller 类中编写了一个特定的处理程序,例如:
@ExceptionHandler(UnprocessableEntityException.class)
@ResponseStatus(HttpStatus.UNPROCESSABLE_ENTITY)
public String handleException(Exception ex) {
...
}
Run Code Online (Sandbox Code Playgroud)
据我了解,我首先不需要@ExceptionHandler,不确定我错过了什么。
失败的原因如下:
BeanWrapperFieldSetMapper.mapFieldSet (第184行)在以下行(第187行):
binder.bind(new MutablePropertyValues(getBeanProperties(copy, fs.getProperties())));
@Override
public Properties getProperties() {
if (names == null) {
throw new IllegalStateException("Cannot create properties without meta data");
}
Run Code Online (Sandbox Code Playgroud)
注意:我没有指定名称,因为我正在尝试Automap.
以下是我的代码:
@Bean
public LineMapper<Partner> lineMapper() {
DefaultLineMapper<Partner> lineMapper = new DefaultLineMapper<Partner>();
DelimitedLineTokenizer lineTokenizer = new DelimitedLineTokenizer();
BeanWrapperFieldSetMapper<Partner> fieldSetMapper = new BeanWrapperFieldSetMapper<Partner>();
fieldSetMapper.setBeanFactory(getApplicationContext());
fieldSetMapper.setTargetType(Partner.class);
lineMapper.setLineTokenizer(lineTokenizer);
lineMapper.setFieldSetMapper(fieldSetMapper);
return lineMapper;
}
Run Code Online (Sandbox Code Playgroud)精确的堆栈跟踪
退出-DESCR.:org.springframework.batch.item.file.FlatFileParseException: Parsing error at line: 1 in resource=[class path resource [partner-import.csv]], input=[Mustermann,Max,dahiya.naveen@gmail.com,m]
引起: java.lang.IllegalStateException: Cannot create properties without meta data
at org.springframework.batch.item.file.transform.DefaultFieldSet.getProperties(DefaultFieldSet.java:745)
我得到一个csv文件作为webservice调用,需要加密.现在我将它保存在临时目录中,以将其作为setResource提供给Reader.
有没有办法提供流(byte [])而不是先保存文件?
在使用 spring cloud 配置时,我遇到了 @RefreshScope。
据我了解,@RefreshScope 必须与任何需要动态更新所用属性的 bean 一起使用。
是否有可以在整个应用程序中使用的全局替代方案,而不仅仅是一个 bean?