MyBatis Plus 项目初始化

注意:本教程使用的数据库脚本、数据模型和环境信息请参考 “MyBatis Plus环境准备” 章节,点击下载示例源码

本教程将介绍怎样快速搭建一个 Spring Boot 项目,在后续的章节中我们均会在该项目的基础上进行学习。

初始化 Spring Boot 项目

我们将使用 IDEA 的 “Spring Initializr”创建一个 Spring Boot 项目。步骤如下:

(1)点击 IDEA “File”、“New”、“Project”菜单,打开创建项目弹框,且选择“Spring Initializr”,JDK 我们选择 1.8,最后点击 “Next”按钮进入下一个步骤。如下图:

(2)在该步骤我们需要填写 maven 项目的 Group、Artifact 和 version 等信息,填写完成后点击“Next”按钮继续。如下图:

(3)下面弹窗键选择使用那些依赖到我们的项目,我这里选择了 Spring Boot DevTools 和 MyBatis Framework,选择完成后点击“Next”继续。如下图:

(4)下面将设置项目保存到磁盘什么位置,以及项目的名称。确定填写无误后,点击“Finish”即可完成项目创建。如下图:

如果你是首次创建 Spring  Boot 项目可能需要等一会儿,maven 会从中心 maven 仓库下载项目依赖。当我们项目初始化完成后,将看到如下图的结构图:

直接进入“main/java” 目录下面,打开包接口,找到 MyBatisPlusLearnApplication.java 程序,该程序是一个拥有 main 方法的程序,直接运行即可。如果你能看见如下日志信息,则说明 Spring Boot 项目启动成功了:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.3.3.RELEASE)

2020-09-18 21:32:03.661  INFO 5944 --- [  restartedMain] c.h.m.MybatisPlusLearnApplication        : Starting MybatisPlusLearnApplication on hxstrive-PC with PID 5944 (D:\learn\JavaDatabase\MyBatis\mybatis-workspaces\mybatis-plus-learn\target\classes started by Administrator in D:\learn\JavaDatabase\MyBatis\mybatis-workspaces)
2020-09-18 21:32:03.667  INFO 5944 --- [  restartedMain] c.h.m.MybatisPlusLearnApplication        : No active profile set, falling back to default profiles: default
2020-09-18 21:32:03.785  INFO 5944 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2020-09-18 21:32:03.785  INFO 5944 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2020-09-18 21:32:05.530  INFO 5944 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2020-09-18 21:32:05.550  INFO 5944 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-09-18 21:32:05.551  INFO 5944 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.37]
2020-09-18 21:32:05.725  INFO 5944 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2020-09-18 21:32:05.726  INFO 5944 --- [  restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1940 ms
2020-09-18 21:32:06.157  INFO 5944 --- [  restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'

说说我的看法
全部评论(

Information:java: Errors occurred while compiling module 'mybatis_plus_learn'

Information:javac 1.8.0_91 was used to compile java sources

Information:Module "mybatis_plus_learn" was fully rebuilt due to project configuration/dependencies changes

Information:2023/3/20 12:25 - Compilation completed with 1 error and 0 warnings in 5 s 993 ms

Error:java: invalid source release: 11

请问这是什么问题?

回复:

把项目的 target 和 idea 的工作目录信息全部删除,重新编译试试呢!并且将编译版本设置为JDK1.8

关于
本网站属于个人的非赢利性网站,转载的文章遵循原作者的版权声明,如果原文没有版权声明,请来信告知:hxstrive@outlook.com
公众号