我在Spring服务中定义了一个长期运行的任务.它由Spring MVC控制器启动.我想HttpResponse在服务结束之前启动服务并返回给调用者.该服务最后将文件保存在文件系统上.在javascript中,我创建了一个轮询工作来检查服务状态.
在Spring 3.2中我找到了@Async注释,但是我不明白它DeferredResult与它的区别Callable.我何时必须使用@Async,何时使用DeferredResult?
我正在尝试将 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.properties:spring.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) 我有一个休息方法:
@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) 我们一直在使用 Jasper 和 Spring Boot 作为我们项目的报告功能,但根据Spring Framework 5.x 发布文档, Jasper 支持已被取消。
他们建议继续使用 Spring Framework 4.3.x,以防我们需要 Jasper 支持。
我在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.为什么会这样?
我进行了许多更改,可能会破坏代码。我以为自己在分行,但是当我下定决心时却是主。有什么方法可以将4个本地提交移动到本地分支然后再推送?
spring-boot ×3
java ×2
mysql ×2
spring ×2
asynchronous ×1
branch ×1
callable ×1
deferred ×1
git ×1
int ×1
integer ×1
nonblocking ×1
spring-mvc ×1