千家信息网

如何通过idea工具创建第一个SpringBoot+Maven项目

发表于:2025-02-03 作者:千家信息网编辑
千家信息网最后更新 2025年02月03日,如何通过idea工具创建第一个SpringBoot+Maven项目,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。1.工作准备:(1)安装
千家信息网最后更新 2025年02月03日如何通过idea工具创建第一个SpringBoot+Maven项目

如何通过idea工具创建第一个SpringBoot+Maven项目,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。

1.工作准备:

(1)安装jdk

(2)安装的intellij idea工具

(3)安装maven

2.在idea中配置maven

(1)文件->设置


3.创建项目

(1)文件->新建



4.配置pom依赖包:

4.0.0org.springframework.bootspring-boot-starter-parent2.0.1.RELEASE com.exampledemo0.0.1-SNAPSHOTdemoDemo project for Spring Boot1.8org.springframework.bootspring-boot-starter-weborg.mybatis.spring.bootmybatis-spring-boot-starter1.3.2mysqlmysql-connector-javaruntimeorg.springframework.bootspring-boot-starter-testtestcom.fasterxml.jackson.corejackson-corecom.fasterxml.jackson.corejackson-databindcom.fasterxml.jackson.datatypejackson-datatype-jodacom.fasterxml.jackson.modulejackson-module-parameter-namescom.alibabadruid1.0.11org.springframework.bootspring-boot-maven-pluginorg.mybatis.generatormybatis-generator-maven-plugin1.3.2${basedir}/src/main/resources/generatorConfig.xmltruetrue

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项目的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注行业资讯频道,感谢各位的阅读!

0