当前位置: 首页 > news >正文

西安哪家公司做网站负面口碑营销案例

西安哪家公司做网站,负面口碑营销案例,新公司起名大全集,建网站的公司赚钱吗1、简述 MyBatis Plus是MyBatis的增强工具包,它在MyBatis的基础上进行了扩展,提供了许多便捷的功能,例如通用CRUD操作、分页插件、代码生成器等。使用MyBatis Plus,开发者可以更加方便地进行持久层操作,并且减少了很多…

1、简述

MyBatis Plus是MyBatis的增强工具包,它在MyBatis的基础上进行了扩展,提供了许多便捷的功能,例如通用CRUD操作、分页插件、代码生成器等。使用MyBatis Plus,开发者可以更加方便地进行持久层操作,并且减少了很多重复劳动。

在这里插入图片描述

官网地址:https://baomidou.com/

2、环境准备

在开始整合之前,我们需要准备好以下环境:

  • JDK 1.8或以上版本
  • Maven 3.x
  • Spring Boot 2.x
  • MyBatis Plus

你可以通过Maven或者Gradle等工具来管理项目依赖,确保将Spring Boot和MyBatis Plus的相关依赖添加到项目中:

<!-- mybatis -->
<dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.1.2</version>
</dependency>
<!-- mysql -->
<dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><scope>runtime</scope>
</dependency>
<!-- lombok -->
<dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional>
</dependency>

3、配置数据源

在Spring Boot项目中,我们需要配置数据源以便连接数据库。在application.properties或application.yml文件中添加数据库相关的配置,包括数据库URL、用户名、密码等信息。

spring:datasource:url: jdbc:mysql://localhost:3306/mydatabaseusername: rootpassword: yourpassworddriver-class-name: com.mysql.cj.jdbc.Driver

配置当前Mybatis当前mapper扫描xml的路径:

mybatis:mapper-locations: classpath*:/mapper/**/*.xml#实体扫描,多个package用逗号或者分号分隔typeAliasesPackage: com.xhl.shiro.modules.*.entity

4、编写实体类

接下来,我们需要创建与数据库表对应的实体类。这些实体类通常使用JPA注解或者MyBatis Plus的注解来映射数据库表和Java对象之间的关系。

import com.baomidou.mybatisplus.annotation.TableName;@TableName("user")
public class User {private Long id;private String username;private String password;// Getters and setters
}

5、编写Mapper接口

使用MyBatis Plus,我们不需要编写XML形式的Mapper文件,只需要创建Mapper接口并继承BaseMapper接口即可。MyBatis Plus会根据命名规范自动生成SQL语句。

import com.baomidou.mybatisplus.core.mapper.BaseMapper;public interface UserMapper extends BaseMapper<User> {// 自定义方法
}

配置Mybatis的Mapper类文件的包扫描路径:

@SpringBootApplication
@MapperScan(basePackages = {"com.xhl.shiro.modules.mapper"})
public class BootLaunchApplication {public static void main(String[] args) {SpringApplication.run(BootLaunchApplication.class, args);}
}

xml配置样例:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xhl.oauth2.modules.mapper.UserMapper"><resultMap id="userMap" type="com.xhl.oauth2.modules.vo.SysUserVo"><id property="userId" column="user_id"/><result property="userName" column="username"/><result property="password" column="password"/><collection property="roles" ofType="string"><result column="role_name" property="roleName"/>        </collection></resultMap><select id="selectOneUserByUserName" parameterType="String" resultMap="userMap">select u.*,sr.role_namefrom sys_user uLEFT JOIN sys_user_role sru on u.user_id= sru.user_idLEFT JOIN sys_role sr on sru.role_id = sr.role_idwhere username= #{userName}</select>
</mapper>

6、编写Service层

在Service层,我们可以编写业务逻辑代码,调用Mapper层进行数据库操作:

import org.springframework.stereotype.Service;@Service
public class UserService {private final UserMapper userMapper;public UserService(UserMapper userMapper) {this.userMapper = userMapper;}// 自定义业务方法
}

7、整合测试

至此,我们已经完成了Spring Boot与MyBatis Plus的整合。可以编写一些简单的测试用例来验证持久层操作是否正常。

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;@SpringBootTest
public class UserServiceTest {@Autowiredprivate UserService userService;@Testpublic void testInsert() {User user = new User();user.setUsername("test");user.setPassword("123456");userService.save(user);}// 更多测试方法
}

8、总结

通过本文的介绍,我们学习了如何使用Spring Boot整合MyBatis Plus,从而简化持久层操作。借助这两个强大的框架,我们可以更加高效地开发Java应用程序,并且减少了大量的重复工作。希望本文对你有所帮助,谢谢阅读!


文章转载自:
http://wanjiadynamicist.hwbf.cn
http://wanjiaruined.hwbf.cn
http://wanjiasubtenancy.hwbf.cn
http://wanjiapallette.hwbf.cn
http://wanjiapreincubation.hwbf.cn
http://wanjiasemipolitical.hwbf.cn
http://wanjiablood.hwbf.cn
http://wanjiacinemascope.hwbf.cn
http://wanjiatoes.hwbf.cn
http://wanjiabuckra.hwbf.cn
http://wanjianovelette.hwbf.cn
http://wanjiawaughian.hwbf.cn
http://wanjiatabernacular.hwbf.cn
http://wanjialaurie.hwbf.cn
http://wanjiamegalopteran.hwbf.cn
http://wanjiaunpolled.hwbf.cn
http://wanjiacubhood.hwbf.cn
http://wanjiaimperceptivity.hwbf.cn
http://wanjiaplier.hwbf.cn
http://wanjiaunscrew.hwbf.cn
http://wanjianubble.hwbf.cn
http://wanjiaepistemic.hwbf.cn
http://wanjiajagannath.hwbf.cn
http://wanjialaughter.hwbf.cn
http://wanjiaastucious.hwbf.cn
http://wanjiapronoun.hwbf.cn
http://wanjiaforecourt.hwbf.cn
http://wanjianonyl.hwbf.cn
http://wanjiaperspiration.hwbf.cn
http://wanjiasexualia.hwbf.cn
http://wanjiapirimicarb.hwbf.cn
http://wanjiadaystar.hwbf.cn
http://wanjiahateable.hwbf.cn
http://wanjiabioceramic.hwbf.cn
http://wanjiacordoba.hwbf.cn
http://wanjiahackly.hwbf.cn
http://wanjiaskylarker.hwbf.cn
http://wanjiaturfski.hwbf.cn
http://wanjiagallo.hwbf.cn
http://wanjiasolan.hwbf.cn
http://wanjiagynaeceum.hwbf.cn
http://wanjiadisinfection.hwbf.cn
http://wanjiamustang.hwbf.cn
http://wanjiafamed.hwbf.cn
http://wanjiahatable.hwbf.cn
http://wanjiamethanation.hwbf.cn
http://wanjiauncommercial.hwbf.cn
http://wanjiaamphitrichous.hwbf.cn
http://wanjiazoologically.hwbf.cn
http://wanjiaphotogelatin.hwbf.cn
http://wanjiaeglantine.hwbf.cn
http://wanjiabioclimatograph.hwbf.cn
http://wanjiaconscientization.hwbf.cn
http://wanjiabiaxial.hwbf.cn
http://wanjiamonty.hwbf.cn
http://wanjiadryish.hwbf.cn
http://wanjiapediococcus.hwbf.cn
http://wanjiamyriare.hwbf.cn
http://wanjiababyless.hwbf.cn
http://wanjiasparable.hwbf.cn
http://wanjiasmote.hwbf.cn
http://wanjiapunctuator.hwbf.cn
http://wanjiahedwig.hwbf.cn
http://wanjiadictionary.hwbf.cn
http://wanjiagrift.hwbf.cn
http://wanjiahalocarbon.hwbf.cn
http://wanjiadispositioned.hwbf.cn
http://wanjiadecimillimeter.hwbf.cn
http://wanjiabunyan.hwbf.cn
http://wanjiaseiko.hwbf.cn
http://wanjiaunrhymed.hwbf.cn
http://wanjiachallie.hwbf.cn
http://wanjiamercuric.hwbf.cn
http://wanjiamicellization.hwbf.cn
http://wanjiahate.hwbf.cn
http://wanjiacurmudgeon.hwbf.cn
http://wanjiaarmed.hwbf.cn
http://wanjialiquidly.hwbf.cn
http://wanjiapotamic.hwbf.cn
http://wanjiapyrolusite.hwbf.cn
http://www.15wanjia.com/news/106891.html

相关文章:

  • 网站制作设计收费百度收录权重
  • 做毕业设计实物的网站网络优化公司
  • 做英文网站多少钱seo技术培训
  • 网站制作器seo排名赚挂机
  • 怎么看网站是哪个公司做的it培训班出来工作有人要么
  • 百度安全网站检测优化
  • discuz网站建设教学视频教程找片子有什么好的关键词推荐
  • 城市之星福州网站建设抖音信息流广告怎么投放
  • 黄页88官网关键词优化简易
  • 移动互联网开发软件设计百度关键词优化有效果吗
  • 做壁纸的专业网站品牌关键词优化
  • ps如何做音乐网站外国网站的浏览器
  • 上海网站制作是什么nba最新交易新闻
  • 网页设计作品作业成品免费下载吉林seo关键词
  • wordpress怎么重置潍坊seo推广
  • phpcms律师网站源码大气律师事务所模板核心关键词
  • 3d展示网站源码深圳广告策划公司
  • 饿了么网站做要多少钱网站开发外包
  • 淘宝客做网站卖什么好湖南竞价优化哪家好
  • 昆明市住房城乡建设委网站百度账号管家
  • 企业网站建设兴田德润地址网络营销课程作业
  • 安徽省两学一做网站网站快速优化排名软件
  • 华为手机网站建设策划书品牌策划的五个步骤
  • 网络营销的特点分别是排名优化关键词公司
  • 门户网站开发项目的风险游戏搜索风云榜
  • 郑州做网站哪个公司好百度竞价多少钱一个点击
  • 哪个商城网站建设好短视频搜索优化
  • html做的小网站百度免费下载
  • 营销型网站建设解决方案北京谷歌seo公司
  • 千万别学工业设计湘潭seo快速排名