构建第一个spring boot应用程序

来源:互联网 发布:oracle数据库接口 编辑:程序博客网 时间:2024/05/14 19:27

这篇文章先介绍搭建一个简单的SpringBoot应用

1、工具:

        开发工具-IntelliJ IDEA

        项目构建工具-maven

        以及我们所熟悉的JDK


        IntelliJ IDEA



  maven




  jdk




2、创建一个新项目之旅由此开始:

        (1) 第一次打开软件会出现这个窗口,选择 Create New Project


(2) 选择 Spring Initializr,Project SDK 选择 1.8,URL 填写默认的,点击 Next



(3) 按照图中红框,填写对应内容,点击 Next



(4) Version 选择1.4.3,Web 这里只需要选择Web一个就行,点击Next



(5) 填写项目名称,项目存放的目录,点击 Finish



(6) 最终的项目展示




(7) 在pom.xml配置H2数据库依赖以及在resources的application.properties中配置数据源


pom.xml

<dependency><groupId>com.h2database</groupId><artifactId>h2</artifactId></dependency>


application.properties

spring.datasource.username=saspring.datasource.password=spring.datasource.driver-class-name=org.h2.Driverspring.datasource.url=jdbc:h2:mem:dbtestspring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialectspring.jpa.show-sql=true

(8) 下面启动项目看看效果

既方便也是最常用的,在启动前先写一个Controller类,这样能看出效果



点击Run下面的Run+项目名称的Application



出现如下信息,代表启动成功



接着我们在浏览器中输入地址 http://localhost:8080/hello 访问一下试试,看到效果了吧









0 0
原创粉丝点击