如何通过idea工具创建第一个SpringBoot+Maven项目
如何通过idea工具创建第一个SpringBoot+Maven项目,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。
1.工作准备:
(1)安装jdk
(2)安装的intellij idea工具
(3)安装maven
2.在idea中配置maven
(1)文件->设置
3.创建项目
(1)文件->新建
4.配置pom依赖包:
4.0.0 org.springframework.boot spring-boot-starter-parent 2.0.1.RELEASE com.example demo 0.0.1-SNAPSHOT demo Demo project for Spring Boot 1.8 org.springframework.boot spring-boot-starter-web org.mybatis.spring.boot mybatis-spring-boot-starter 1.3.2 mysql mysql-connector-java runtime org.springframework.boot spring-boot-starter-test test com.fasterxml.jackson.core jackson-core com.fasterxml.jackson.core jackson-databind com.fasterxml.jackson.datatype jackson-datatype-joda com.fasterxml.jackson.module jackson-module-parameter-names com.alibaba druid 1.0.11 org.springframework.boot spring-boot-maven-plugin org.mybatis.generator mybatis-generator-maven-plugin 1.3.2 ${basedir}/src/main/resources/generatorConfig.xml true true
5.配置spring的资源文件:application.yml
server:
port: 8082
spring:
datasource:
name: test
url: jdbc:mysql://127.0.0.1:3306/testDB
username: root
password: root
# 使用druid数据源
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver
filters: stat
maxActive: 20
initialSize: 1
maxWait: 60000
minIdle: 1
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: select 'x'
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
maxOpenPreparedStatements: 20
## 该配置节点为独立的节点,有很多同学容易将这个配置放在spring的节点下,导致配置无法被识别
mybatis:
mapper-locations: classpath:mapping/*.xml #注意:一定要对应mapper映射xml文件的所在路径
type-aliases-package: com.example.model # 注意:对应实体类的路径
看完上述内容,你们掌握如何通过idea工具创建第一个SpringBoot+Maven项目的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注行业资讯频道,感谢各位的阅读!