how-to-access-in-memory-h2-database-of-one-spring-boot-application-from-another
需要加一个启动h2database的server
@SpringBootApplication
@MapperScan("com.qctc.activiti.mapper")
public class ActivitiApplication {
public static void main(String[] args) {
SpringApplication.run(ActivitiApplication.class, args);
}
@Bean(initMethod = "start", destroyMethod = "stop")
public Server h2Server() throws SQLException {
return Server.createTcpServer("-tcp", "-tcpAllowOthers", "-tcpPort", "9092");
}
}
server:
port: 9090
spring:
datasource:
driver-class-name: org.h2.Driver
url: jdbc:h2:./db/H2/testdb
username: root
password: root
h2:
console:
enabled: true #开启web console功能
path: /h2
settings:
web-allow-others: true
http://localhost:9090/h2 直接访问,可以登陆上
使用idea的database连接
可以查看到表了