pom添加mysql依赖tomcat崩溃_Spring Boot + Mybatis + Spring MVC环境配置(一) :Spring Boot初始化,依赖添加...

最近在搭建一个Spring Boot + Mybatis + Spring MVC的环境,折腾来折腾去,两三天才搞定,记录下大概过程和遇到的错误

看一下Spring Boot官方的介绍

a4d45be817e1ade015a1549b6b3faaf8.png

Spring Boot让开发者省去了大多数Spring的配置,让其只需要关注主要的开发和进行少量的Spring配置。

嵌入了Tomcat,已定义好大多数的依赖关系,简化了项目的构建配置。我们在使用的时候不用关心框架之间的兼容性,适用版本等问题,想使用的东西,仅仅添加一个配置就可以了,所以使用spring boot非常适合构建微服务。

第一步,访问

生成一个spring boot项目

8754f0be34cca4c55e7f42aadadb0cfd.png

生成之后会下载一个压缩包,解压后,在Eclipse中Import为Maven项目

第二步,添加额外需要的依赖,如Mybatis

pom.xml内容如下:

xmlns:xsi="

xsi:schemaLocation="

4.0.0

com.kai

demo

0.0.1-SNAPSHOT

jar

demo

Demo project for Spring Boot

org.springframework.boot

spring-boot-starter-parent

2.0.4.RELEASE

UTF-8

UTF-8

1.8

org.springframework.boot

spring-boot-starter

org.springframework.boot

spring-boot-starter-test

test

org.springframework.boot

spring-boot-starter-web

org.springframework.boot

spring-boot-devtools

true

mysql

mysql-connector-java

org.mybatis

mybatis

3.4.6

org.mybatis

mybatis-spring

1.3.2

org.apache.logging.log4j

log4j

2.11.1

pom

org.springframework

spring-jdbc

com.zaxxer

HikariCP

3.2.0

org.springframework.boot

spring-boot-maven-plugin

true

引入web模块

Starter for building web, including RESTful, applications using Spring MVC. Uses Tomcat as the default embedded container

org.springframework.boot

spring-boot-starter-web

pom.xml文件中默认有两个模块:

spring-boot-starter:核心模块,包括自动配置支持、日志和YAML;

spring-boot-starter-test:测试模块,包括JUnit、Hamcrest、Mockito。

开发环境的调试

热启动在正常开发项目中已经很常见了吧,虽然平时开发web项目过程中,改动项目启重启总是报错;但springBoot对调试支持很好,修改之后可以实时生效,需要添加以下的配置:

org.springframework.boot

spring-boot-devtools

true

org.springframework.boot

spring-boot-maven-plugin

true

完整环境下载地址:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值