小编brg*_*rgs的帖子

Spring异步文件上传和处理

我正在尝试上传文件然后阅读它,一切正常,但是当我@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)

spring spring-mvc

11
推荐指数
1
解决办法
5277
查看次数

如何验证pem证书的密码

正如标题所说。我可以使用 php 轻松验证openssl_pkcs12_readp12 证书的密码,但似乎 pem 没有类似的功能。也许用 pem 做这件事是不可能的?

openssl certificate

5
推荐指数
2
解决办法
3万
查看次数

标签 统计

certificate ×1

openssl ×1

spring ×1

spring-mvc ×1