打开idea,左上角文件》》新建》》项目》》文件路径与名字(路径尽量不出现中文》》完成

等待右下角依赖性解析完成,随后打开左边pom.xml依赖,其中只包含保证运行的基本依赖和一个lombok

  <!-- Mybatis Plus整合-->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.4.2</version>
        </dependency>

        <!--Web支持(Spring Mvc)-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!--模板引擎thymeleaf整合-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

       <!--mysql-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        
		<!--lombok-->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>

修改配置文件在resources目录下新建yml文件(也可不新建,直接在application.properties中配置,但是yml文件可以使用缩进的形式省略重复的内容,语法比properties简洁)

 

spring:
  thymeleaf:
    cache: false # 关闭缓存,默认开启
  #    prefix: classpath:/pages/  #修改默认路径 classpath:/templates/
  datasource:
    url: jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=utf-8&serverTimezone=CTT
    username: root
    password:
    driver-class-name: com.mysql.cj.jdbc.Driver

# mybatis-plus配置
mybatis-plus:
  configuration:
    # 是否开启自动驼峰命名规则(camel case)映射,即从经典数据库列名 A_COLUMN(下划线命名) 到经典 Java 属性名 aColumn(驼峰命名) 的类似映射
    map-underscore-to-camel-case: true
    # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
  #MyBaits 别名包扫描路径,通过该属性可以给包中的类注册别名
  type-aliases-package: com.company.springboot.entity
  #xml扫描,多个目录用逗号或者分号分隔(告诉 Mapper 所对应的 XML 文件位置)
  mapperLocations: classpath:mapper/*.xml

一个项目就创建完毕了。


版权声明:本文为Edward_Mcc原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/Edward_Mcc/article/details/122518092