idea 中新建springboot项目步骤如图配置文件配置文件可以是properties或是yml看个人使用习惯及公司开发要求比较推荐yml层级分明在项目中选中配置文件右键可以切换文件类型.propertiesspring.application.nameStudentClassDemo# 数据库连接spring.datasource.driver-class-namecom.mysql.cj.jdbc.Driverspring.datasource.urljdbc:mysql://localhost:3306/数据库名spring.datasource.username用户名spring.datasource.password密码server.port端口号默认8080可省略# mybaits文件加载位置mybatis.mapper-locationsclasspath:mapper/*Mapper.xml# 开启驼峰命名mybatis.configuration.map-underscore-to-camel-casetrue# 开启日志mybatis.configuration.log-implorg.apache.ibatis.logging.stdout.StdOutImpl.ymlmybatis: configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl map-underscore-to-camel-case:truemapper-locations: classpath:mapper/*Mapper.xml server: port: 端口号 spring: application: name: StudentClassDemo datasource: driver-class-name: com.mysql.cj.jdbc.Driver password: 密码 url: jdbc:mysql://localhost:3306/数据库名 username: 用户名pom.xml依赖dependencies!-- springboot启动 --dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependency!-- mybatis集成启动 --dependencygroupIdorg.mybatis.spring.boot/groupIdartifactIdmybatis-spring-boot-starter/artifactIdversion3.0.5/version/dependency!-- mysql数据库连接 --dependencygroupIdcom.mysql/groupIdartifactIdmysql-connector-j/artifactIdscoperuntime/scope/dependency!-- lombok --dependencygroupIdorg.projectlombok/groupIdartifactIdlombok/artifactIdoptionaltrue/optional/dependency!-- 单元测试 --dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependency!--测试用 简化mybatis接口的单元测试--dependencygroupIdorg.mybatis.spring.boot/groupIdartifactIdmybatis-spring-boot-starter-test/artifactIdversion3.0.5/versionscopetest/scope/dependency!-- pagehelper分页插件 --dependencygroupIdcom.github.pagehelper/groupIdartifactIdpagehelper-spring-boot-starter/artifactIdversion1.4.6/version/dependency/dependencies后续持续更新内容······
idea中新建springboot项目步骤,并添加数据库配置,pom文件依赖,附源码
idea 中新建springboot项目步骤如图配置文件配置文件可以是properties或是yml看个人使用习惯及公司开发要求比较推荐yml层级分明在项目中选中配置文件右键可以切换文件类型.propertiesspring.application.nameStudentClassDemo# 数据库连接spring.datasource.driver-class-namecom.mysql.cj.jdbc.Driverspring.datasource.urljdbc:mysql://localhost:3306/数据库名spring.datasource.username用户名spring.datasource.password密码server.port端口号默认8080可省略# mybaits文件加载位置mybatis.mapper-locationsclasspath:mapper/*Mapper.xml# 开启驼峰命名mybatis.configuration.map-underscore-to-camel-casetrue# 开启日志mybatis.configuration.log-implorg.apache.ibatis.logging.stdout.StdOutImpl.ymlmybatis: configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl map-underscore-to-camel-case:truemapper-locations: classpath:mapper/*Mapper.xml server: port: 端口号 spring: application: name: StudentClassDemo datasource: driver-class-name: com.mysql.cj.jdbc.Driver password: 密码 url: jdbc:mysql://localhost:3306/数据库名 username: 用户名pom.xml依赖dependencies!-- springboot启动 --dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependency!-- mybatis集成启动 --dependencygroupIdorg.mybatis.spring.boot/groupIdartifactIdmybatis-spring-boot-starter/artifactIdversion3.0.5/version/dependency!-- mysql数据库连接 --dependencygroupIdcom.mysql/groupIdartifactIdmysql-connector-j/artifactIdscoperuntime/scope/dependency!-- lombok --dependencygroupIdorg.projectlombok/groupIdartifactIdlombok/artifactIdoptionaltrue/optional/dependency!-- 单元测试 --dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependency!--测试用 简化mybatis接口的单元测试--dependencygroupIdorg.mybatis.spring.boot/groupIdartifactIdmybatis-spring-boot-starter-test/artifactIdversion3.0.5/versionscopetest/scope/dependency!-- pagehelper分页插件 --dependencygroupIdcom.github.pagehelper/groupIdartifactIdpagehelper-spring-boot-starter/artifactIdversion1.4.6/version/dependency/dependencies后续持续更新内容······