我正在尝试上传文件然后阅读它,一切正常,但是当我@Async在处理程序方法上添加注释时却没有.
我不希望用户在处理文件之前一直等待.但是在放入这个注释之后我得到了java.lang.IllegalStateException: File has been moved - cannot be read again例外.会发生什么,我该如何解决这个问题?据我所知,Spring可能只是清除文件,因为请求 - 响应结束并清理它.但是不应该@Async阻止这个?
示例Spring Boot应用程序:
@SpringBootApplication
@EnableSwagger2
@ComponentScan(value = "hello")
@EnableAsync
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.regex("/api/.*"))
.build();
}
}
Run Code Online (Sandbox Code Playgroud)
上传控制器:
@RestController
@RequestMapping(value = "/files")
public class FilesController {
@Inject
private Upload upload;
@RequestMapping(method = RequestMethod.POST)
public void addSource(@RequestParam MultipartFile file) throws IOException, InterruptedException {
upload.process(file);
} …Run Code Online (Sandbox Code Playgroud) 正如标题所说。我可以使用 php 轻松验证openssl_pkcs12_readp12 证书的密码,但似乎 pem 没有类似的功能。也许用 pem 做这件事是不可能的?