idea spring boot mybatis plus使用配置

5 篇文章 0 订阅
5 篇文章 0 订阅

概况

主要在于 mapper-locations 和pom中的区别。

  • mapper-locations 跟据自己实际的位置写。
  • idea编辑器下。如果xml文件放在了java目录则需要配置下面资源目录。否则无需配置。

application.yaml

mybatis-plus:
  global-config:  #全局配置
    db-config:  #数据库配置
      id-type: auto   #主键id自增
  configuration: #原来的mybais的配置 
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #开启sql日志
  mapper-locations: classpath:com/example/demo/mapper/xml/*.xml #映射xml文件位置
  type-aliases-package: com.example.demo.entity #实体类包名

pom

    <build>
        <resources>
            <resource>
                <!-- xml放在java目录下-->
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>
            <!--自定义resource之后 默认值失效,必须重新指定-->
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
    </build>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是基于 Spring BootMyBatis-Plus、Thymeleaf 和 Bootstrap 的留言板的实现步骤: 1. 创建 Spring Boot 项目 在 IDEA 中创建一个 Spring Boot 项目,选择 Web 和 Thymeleaf 作为依赖。 2. 添加 MyBatis-Plus 依赖 在 pom.xml 文件中添加 MyBatis-Plus 依赖: ```xml <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.4.0</version> </dependency> ``` 3. 创建留言板数据表 在 MySQL 中创建一个名为 message_board 的数据表,包含以下字段: ```sql CREATE TABLE `message_board` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL COMMENT '留言人姓名', `email` varchar(50) NOT NULL COMMENT '留言人邮箱', `content` varchar(255) NOT NULL COMMENT '留言内容', `create_time` datetime NOT NULL COMMENT '创建时间', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='留言板'; ``` 4. 创建 MyBatis-Plus 实体类和 Mapper 使用 MyBatis-Plus 的代码生成器,生成 Message 实体类和 MessageMapper 接口。 5. 编写 Service 层 创建 MessageService 接口和 MessageServiceImpl 实现类,其中 MessageServiceImpl 实现类注入 MessageMapper,实现增删改查等方法。 6. 编写 Controller 层 创建 MessageController 类,其中注入 MessageService,实现留言板的展示、添加留言和删除留言等功能。 7. 编写 Thymeleaf 页面 在 templates 目录下创建 message.html 页面,使用 Thymeleaf 和 Bootstrap 实现留言板的展示和添加留言的表单。 8. 运行项目 使用 IDEA 运行项目,在浏览器中访问 http://localhost:8080/message 即可看到留言板页面。 以上就是基于 Spring BootMyBatis-Plus、Thymeleaf 和 Bootstrap 的留言板的实现步骤,你可以参考这些步骤来实现自己的留言板。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值