小编Sri*_*911的帖子

Spring MVC的@ Async,DeferredResult和Callable之间的区别

我在Spring服务中定义了一个长期运行的任务.它由Spring MVC控制器启动.我想HttpResponse在服务结束之前启动服务并返回给调用者.该服务最后将文件保存在文件系统上.在javascript中,我创建了一个轮询工作来检查服务状态.

在Spring 3.2中我找到了@Async注释,但是我不明白它DeferredResult与它的区别Callable.我何时必须使用@Async,何时使用DeferredResult

asynchronous spring-mvc callable deferred

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

Spring boot 无法从数据源(mysql)确定 jdbc url

我正在尝试将 MySQL 数据库加载到 Spring Boot 应用程序中,但是当我启动应用程序时,我收到以下错误消息:

2018-07-17 13:46:31.426 WARN 2120 --- [ restartedMain] o.s.b.a.orm.jpa.DatabaseLookup : Unable to determine jdbc url from datasource

org.springframework.jdbc.support.MetaDataAccessException: Could not get Connection for extracting meta-data; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection: 'url' not set

虽然我已经将 url 属性设置为application.propertiesspring.datasource.url=jdbc:mysql://localhost:3306/mydatabase

谁能帮我解决这个问题?

编辑:这是我的主要课程:

package com.randomsoft.checkoff;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;

@SpringBootApplication
@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class})
public class CheckoffApplication {

public static void main(String[] args) {
    SpringApplication.run(CheckoffApplication.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)

java mysql spring spring-data-jpa spring-boot

7
推荐指数
2
解决办法
4万
查看次数

如何在 Spring Boot 中处理 DeferredResult 中的异常?

我有一个休息方法:

@RequestMapping(value = "wash/washHistory", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public DeferredResult<String> getWashHistory(@RequestParam(value = "sid", required = true, defaultValue = "") String sid,
            HttpServletResponse response, HttpServletRequest request,
            @RequestParam(value = "sort", defaultValue = "") String sortType,
            @RequestParam(value = "order", defaultValue = "") String order,
            @RequestParam(value = "limit", defaultValue = "") String limit,
            @RequestParam(value = "offset", defaultValue = "") String offset) {

        System.out.println("Thread: "+Thread.currentThread());
        final Integer managerId = checkSession(sid);      
        DeferredResult<String> defResult = new DeferredResult<>();
        new Thread(() -> {
                final String result …
Run Code Online (Sandbox Code Playgroud)

java spring nonblocking spring-boot

4
推荐指数
1
解决办法
3369
查看次数

为什么从 Spring Framework 5.x 中退出对 Jasper 的支持?

我们一直在使用 Jasper 和 Spring Boot 作为我们项目的报告功能,但根据Spring Framework 5.x 发布文档, Jasper 支持已被取消。

  • 我可以知道为什么这样做吗?

他们建议继续使用 Spring Framework 4.3.x,以防我们需要 Jasper 支持。

  • 如果我们想升级到 Spring Framework 5.x 并且仍然使用 Jasper 怎么办,是否有其他选择?

jasper-reports spring-boot

4
推荐指数
1
解决办法
2032
查看次数

MYSQL中int(11)数据类型面临的问题

我在MYSQL中有一个表,主键id为int(11)(自动递增).现在我有一个程序读取一些文本文件并在id列中输入值.所以我的桌子应该包含:

id
897413
791783
Run Code Online (Sandbox Code Playgroud)


但结果是,我在桌子上找不到大数字.这是因为int(11)可以容纳的最大值吗?将int(11)增加到int(20)仍然面临同样的问题.我无法将数据类型更改为big int,因为我已经实现了很多代码.

编辑:我试图插入id为523826的单个记录,并将其保存在DB中为450258.为什么会这样?

mysql int integer

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

错误地致力于本地掌握。如何将更改移到分支?

我进行了许多更改,可能会破坏代码。我以为自己在分行,但是当我下定决心时却是主。有什么方法可以将4个本地提交移动到本地分支然后再推送?

git branch

0
推荐指数
2
解决办法
2321
查看次数