Spring boot without database

时间:2017-04-13 14:52:21

标签: mysql spring spring-boot spring-data

So one of the cool things I like about spring boot is that it can deploy its own jetty server when launched.

Is it possible to have spring boot deploy its own MySQL without having it installed on the machine?

I understand this sounds silly, but in my case I want database to be initialized every time I run spring boot, and I want it cleared up every time I stop it.

2 个答案:

答案 0 :(得分:3)

Just read the Spring Boot docs:

Spring Boot can auto-configure embedded H2, HSQL and Derby databases. You don’t need to provide any connection URLs, simply include a build dependency to the embedded database that you want to use.

https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-sql.html

答案 1 :(得分:1)

此外还有@streetturtle's回答。您还可以在系统上安装已安装的数据库,并通过使用jpa启动和停止spring-boot应用程序来创建,更新或删除数据库。

private void comboBox9_DropDown(object sender, EventArgs e) { //Load Com Port List into comboBoxes when dropdown. Holds list actual comboBox9.Items.Clear(); string[] portNames = SerialPort.GetPortNames(); //<-- Reads all available comPorts foreach (var portName in portNames) { comboBox9.Items.Add(portName); //Removes comboBox entry if port is Open if (_serialPort1.IsOpen) { comboBox9.Items.Remove(_serialPort1.PortName); } } }