【新建springBoot+mybatis Demo,基于IDEA】

新建springBoot+mybatis Demo,基于IDEA

1、新建springboot项目

1.1、文件-新建项目-Spring Initialzr,下一步
在这里插入图片描述
Group Id、Artifact Id、Project name等可根据实际情况填写,下一步。
在这里插入图片描述
web选择spring web
在这里插入图片描述

Template Engines选择 Thymeleaf
在这里插入图片描述

SQL选择Spring Data JPA、MySQL Driver、MyBatis Famework,下一步,
在这里插入图片描述
项目位置及项目名称可按实际情况填写,然后点击完成,等待IDEA配置项目中所需要的jar包
在这里插入图片描述

2、等待项目中的jar包加载完成后创建自己的第一个demo

springboot启动类DemoApplication,这里在注解@SpringBootApplication中添加了一个
在这里插入图片描述

在项目目录下新建controller包,再新建一个controller类
在这里插入图片描述
运行DemoApplication就可以显示自己的第一个demo了
在这里插入图片描述

3、创建过程中遇到了问题:
3.1、数据库未连接,导致报如下错误:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
解决方式,比较直接,在启动类的注解中添加:@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)如图,即可:
在这里插入图片描述
3.2、启动完成后,在浏览器中输入:http://localhost:8080报错
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
原因:1、地址写错:应该写成:http://localhost:8080/index
2、在启动类的注解中添加了如下内容:scanBasePackages = “controller”
在这里插入图片描述
结尾:整体的过程不是很难,百度解决大部分问题0^0

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

番茄蛋子

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值