Spring Boot+Maven 工程配置h2内存数据库

来源:互联网 发布:湄公河大案泰国 知乎 编辑:程序博客网 时间:2024/04/30 11:31

1.新建Maven工程,pom配置:

这样就引入了Spring Boot
<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>1.3.1.RELEASE</version></parent><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>com.h2database</groupId><artifactId>h2</artifactId></dependency>
和h2数据库的依赖架包。

2.创建文件夹src/main/resources,新建文件application.properties,加入配置

spring.h2.console.enabled=true
3.新建java类,
import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplicationpublic class App {    public static void main( String[] args )    {       SpringApplication.run(App.class, args);    }}
右击,run as Java Application

运行之后在浏览器中访问localhost:8080/h2-console即可进入h2配置页面,可以选择语言为中文。

0 0
原创粉丝点击