pom添加mysql依赖tomcat崩溃_Spring Boot + Mybatis + Spring MVC环境配置(一) :Spring Boot初始化,依赖添加...
最近在搭建一個Spring Boot + Mybatis + Spring MVC的環境,折騰來折騰去,兩三天才搞定,記錄下大概過程和遇到的錯誤
看一下Spring Boot官方的介紹
:
Spring Boot讓開發者省去了大多數Spring的配置,讓其只需要關注主要的開發和進行少量的Spring配置。
嵌入了Tomcat,已定義好大多數的依賴關系,簡化了項目的構建配置。我們在使用的時候不用關心框架之間的兼容性,適用版本等問題,想使用的東西,僅僅添加一個配置就可以了,所以使用spring boot非常適合構建微服務。
第一步,訪問
生成一個spring boot項目
生成之后會下載一個壓縮包,解壓后,在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
完整環境下載地址:
總結
以上是生活随笔為你收集整理的pom添加mysql依赖tomcat崩溃_Spring Boot + Mybatis + Spring MVC环境配置(一) :Spring Boot初始化,依赖添加...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 混合模式程序集是针对“v2.0.5072
- 下一篇: WINCE系统的PDA开发 xp系统+V