我正在尝试使用 H2 数据库创建一个 Spring Boot 项目,其他程序可以访问该项目。
应用程序属性
spring.datasource.url = jdbc:h2:tcp://localhost:8084/~/./db/tech
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.datasource.initialization-mode=always
Run Code Online (Sandbox Code Playgroud)
SpringBootMyApplication.java
@SpringBootApplication
public class SpringBootMyApplication{
public static void main(String[] args) {
SpringApplication.run(SpringBootMyApplication.class, args);
}
@Bean(initMethod = "start", destroyMethod = "stop")
public Server h2Server() throws SQLException {
return Server.createTcpServer("-tcp", "-tcpAllowOthers", "-tcpPort", "8084");
}
}
Run Code Online (Sandbox Code Playgroud)
例外是:
Caused by: org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database "C:/Users/onz03589/db/tech" not found, either pre-create it or allow remote database creation (not recommended in secure environments) [90149-200]
Run Code Online (Sandbox Code Playgroud)
如何真正“允许创建远程数据库”?
我有一个简单的代码,点击按钮后模仿数据处理:
@Route("long")
public class LongWait extends VerticalLayout {
public LongWait() {
Button processButton = new Button("Process");
processButton.addClickListener(event -> process());
add(processButton);
}
//imitates processing data:
//should sleep for 10 minutes and then add "finished" label
//instead loose connection after 5 minutes
private void process() {
try {
Thread.sleep(10 * 60 * 1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
add(new Label("finished"));
}
}
Run Code Online (Sandbox Code Playgroud)
问题是 - 在"处理"5分钟后浏览器与服务器松散连接.
为什么会发生这种情况以及如何避免它?
(我真的需要处理大量数据.)
Vaadin:10.0.3
Tomcat:9.0.8
Java:1.8.0_162
UPD:
之后process()方法已经完成它的工作(经过10分钟),我有以下的日志错误:
java.lang.UnsupportedOperationException: Confirmed duplicate message from the …Run Code Online (Sandbox Code Playgroud) 我需要处理一些数据并在网页上显示处理日志。(大约300行文字)。
我试图使用标签。最初,它工作正常-页面变得可滚动,并且所有文本都可以看到。但是大约100个标签后,页面变得没有响应。
如何管理这项任务?
(我尝试在webcomponents.org上寻找其他组件,但找不到任何东西。)
所以我有三个这样的按钮.
我的目标是使这些按钮具有相同的宽度.
要做到这一点,我想检查每个按钮的宽度,将最大值(在这种情况下 - 第二个按钮)放在一个变量中,然后将每个按钮的宽度设置为此值.
我不想使用一些幻数设置宽度,因为我的按钮上的文字可能会改变.
我试着这样做:
String maxWidth = findMaxValue(button1.getWidth(), button2.getWidth(), button3.getWidth());
button1.setWidth(maxWidth);
button2.setWidth(maxWidth);
button3.setWidth(maxWidth);
Run Code Online (Sandbox Code Playgroud)
getWidth()如果未setWidth事先使用该方法设置,则问题是返回null .那么,我如何找出按钮的宽度?