Spring Boot 搭建

环境:Jdk1.8、IntelliJ IDEA 2019.1.2、Tomcat.8.0.36

选择New Project->Spring Initializr来构建,默认的Initializr的Service URL为 https://start.spring.io

Spring Boot 搭建_第1张图片

groupId和artifactId是maven管理项目包时用作区分的字段,就像是地图上的坐标。

groupId:groupId分为几个字段,例如com.piggy,前面的com叫【域】,后面的是你自己起的域名。

artifactId:artifactId一般是项目名或者模块名。

Group:com.yuan

Artifact:boke

Spring Boot 搭建_第2张图片

在Dependencies选择

Web->Spring Web

SQL->Mybatis Framework和MySQL Driver

Spring Boot 搭建_第3张图片

简单的测试项目的搭建,只需要配置一下端口就行

application.properties文件

此处需要配置数据库,不然会出现报错,Spring Boot 虽然做了很多默认的配置,但是它没办法知道你用什么数据库,数据库名称、用户名、密码是什么

server.port=8089

spring.datasource.url=jdbc:mysql://localhost:3306/boke?useUnicode=true&zeroDateTimeBehavior=convertToNull&autoReconnect=true
spring.datasource.username=hap_dev
spring.datasource.password=hap_dev
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
必编写测试类:

Spring Boot 搭建_第4张图片

 

启动run->TrainingApplication

Spring Boot 搭建_第5张图片

你可能感兴趣的:(Java,Spring,Boot)