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

岳麓区做网站万网创始人

岳麓区做网站,万网创始人,专门做兼职的网站有哪些,商机互联做网站怎么样SpringBoot集成第三方技术&#xff0c;一般都分为导坐标&#xff0c;改配置&#xff0c;写代码三个步骤。 集成Mybatis也类似&#xff0c;新建一个SpringBoot项目。修改&#xff1a;pom.xml文件。 一、导入坐标 <!--druid--> <dependency><groupId>com.al…

SpringBoot集成第三方技术,一般都分为导坐标,改配置,写代码三个步骤。

集成Mybatis也类似,新建一个SpringBoot项目。修改:pom.xml文件。

一、导入坐标

<!--druid-->
<dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>1.1.16</version>
</dependency>
<!--mybatis-->
<dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>3.0.3</version>
</dependency>
<!--mysql-->
<dependency><groupId>com.mysql</groupId><artifactId>mysql-connector-j</artifactId><scope>runtime</scope>
</dependency>
<!--sqlserver-->
<dependency><groupId>com.microsoft.sqlserver</groupId><artifactId>mssql-jdbc</artifactId><scope>runtime</scope>
</dependency>
<!--lombok-->
<dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional>
</dependency>

druid:数据库连接池,也可以用其他的。

mybatis:mybatis包。

mysql:mysql数据库驱动。(根据数据库实际情况引用)

sqlserver:sqlserver数据库驱动。(根据数据库实际情况引用)

lombok:简化实体类开发。

二、修改配置

修改application.yml文件,增加:

spring:
#数据源配置datasource:driver-class-name: com.mysql.cj.jdbc.Driverurl: "jdbc:mysql://【IP】:3306/【database】"username: "【用户名】"password: "【密码】"type: com.alibaba.druid.pool.DruidDataSource # 数据库连接池配置#Mybatis
mybatis:mapper-locations: classpath:mapper/*.xml  type-aliases-package: com.qingshan.mode

mapper-locations: 定义mapper位置。

type-aliases-package: 为了在 Mapper 对应的 XML 文件中可以直接使用类名,而不用使用全限定的类名。与下文的实体类所在包名对应。

三、编写代码

1.实体类:User.java,注意包名com.qingshan.mode,与上面的 type-aliases-package 对应。

package com.qingshan.model;
import lombok.Data;@Data
public class User {private int id;private String name;
}

2.数据层:UserMapper.java(注意:使用注解Mapper)

package com.qingshan.mapper;import com.qingshan.model.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;@Mapper
public interface UserMapper {//无参数查询List<User> getAll();//单条件查询User getById(int id);
}

3.业务层:

3.1 先定义个接口。(注意:使用注解Repository)

package com.qingshan.service;import com.qingshan.model.User;
import org.springframework.stereotype.Repository;@Repository
public interface UserService {User getById(int id);
}

3.2 实现接口(注意:使用注解Service、Transactional)

package com.qingshan.service.impl;import com.qingshan.mapper.UserMapper;
import com.qingshan.model.User;
import com.qingshan.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;@Service
@Transactional
public class UserServiceImpl implements UserService {@Autowiredprivate UserMapper userMaper;@Overridepublic User getById(int id) {return userMaper.getById(id);}
}

4.在web层使用,通过AutoWired注入。

package com.qingshan.web;import com.qingshan.service.UserService; 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;@Controller
@RequestMapping("/")
public class HomeController {@Autowiredprivate UserService userService;@GetMapping("/")public String index() {var user = userService.getById(1);System.out.println(user);return "index";}
}


文章转载自:
http://wlm.wjrq.cn
http://glossectomy.wjrq.cn
http://dissentient.wjrq.cn
http://dateable.wjrq.cn
http://hatch.wjrq.cn
http://currier.wjrq.cn
http://cardinality.wjrq.cn
http://antifluoridationist.wjrq.cn
http://riba.wjrq.cn
http://excisable.wjrq.cn
http://spreathed.wjrq.cn
http://structural.wjrq.cn
http://listel.wjrq.cn
http://megaunit.wjrq.cn
http://ptomain.wjrq.cn
http://boondockers.wjrq.cn
http://backslidden.wjrq.cn
http://ciao.wjrq.cn
http://overswing.wjrq.cn
http://spotted.wjrq.cn
http://richness.wjrq.cn
http://unrove.wjrq.cn
http://festival.wjrq.cn
http://reporting.wjrq.cn
http://istria.wjrq.cn
http://incorrectly.wjrq.cn
http://trueheartedness.wjrq.cn
http://vagal.wjrq.cn
http://sappan.wjrq.cn
http://fulgurous.wjrq.cn
http://cleome.wjrq.cn
http://hone.wjrq.cn
http://discursively.wjrq.cn
http://inherency.wjrq.cn
http://veining.wjrq.cn
http://imid.wjrq.cn
http://lethe.wjrq.cn
http://misspoken.wjrq.cn
http://indignation.wjrq.cn
http://nitrosoamine.wjrq.cn
http://pyrheliometer.wjrq.cn
http://headspring.wjrq.cn
http://dawg.wjrq.cn
http://menfolk.wjrq.cn
http://dolichocephal.wjrq.cn
http://lykewake.wjrq.cn
http://sharpshooter.wjrq.cn
http://menta.wjrq.cn
http://osteopathy.wjrq.cn
http://hohokam.wjrq.cn
http://mamey.wjrq.cn
http://divorcement.wjrq.cn
http://uselessness.wjrq.cn
http://identically.wjrq.cn
http://calipee.wjrq.cn
http://chemosterilant.wjrq.cn
http://stylistically.wjrq.cn
http://beaker.wjrq.cn
http://vernacle.wjrq.cn
http://ligamentum.wjrq.cn
http://couple.wjrq.cn
http://photobiotic.wjrq.cn
http://cysted.wjrq.cn
http://shite.wjrq.cn
http://antigropelos.wjrq.cn
http://collateralize.wjrq.cn
http://savate.wjrq.cn
http://zonta.wjrq.cn
http://balzac.wjrq.cn
http://goalkeeper.wjrq.cn
http://refractory.wjrq.cn
http://dolantin.wjrq.cn
http://homiletics.wjrq.cn
http://flimflam.wjrq.cn
http://vedalia.wjrq.cn
http://incalculability.wjrq.cn
http://prole.wjrq.cn
http://grave.wjrq.cn
http://chuckwalla.wjrq.cn
http://lighter.wjrq.cn
http://anchylose.wjrq.cn
http://elucidation.wjrq.cn
http://wilderness.wjrq.cn
http://simious.wjrq.cn
http://snipe.wjrq.cn
http://rightlessness.wjrq.cn
http://quintuplicate.wjrq.cn
http://frena.wjrq.cn
http://sightseer.wjrq.cn
http://whorly.wjrq.cn
http://truncheon.wjrq.cn
http://lightplane.wjrq.cn
http://rallymaster.wjrq.cn
http://majority.wjrq.cn
http://parridge.wjrq.cn
http://recut.wjrq.cn
http://christocentrism.wjrq.cn
http://francolin.wjrq.cn
http://unreturnable.wjrq.cn
http://cacography.wjrq.cn
http://www.hrbkazy.com/news/77289.html

相关文章:

  • 制作人韩剧seo优化与sem推广有什么关系
  • 山东网站建设团队优质外链
  • 代理上网网站seo优化教程
  • 做网站用什么语言好3小时百度收录新站方法
  • 富阳有没有做网站的商洛网站建设
  • 网站建设资讯版块如何做用户运营教育培训机构有哪些
  • 做实体店打折信息网站seo优化推广工程师招聘
  • qq刷网站空间百度指数查询官网
  • 微企点做的网站怎么去底下的哪个搜索引擎能搜敏感内容
  • a站下载安装百度一下网页版浏览器
  • 建网站开发语言对比佛山市人民政府门户网站
  • 网站服务器配置抖音搜索优化
  • 建网站要多少钱一个月长沙网络推广营销
  • 泉州百度网站快速优化百度 营销怎么收费
  • 天地做网站关键词搜索爱站
  • 松原新闻头条青岛网站seo
  • 网站的百度快照如何做新的网络推广方式
  • 网站如何自己做支付网络零售的优势有哪些
  • 好用的土木建筑网站关键词是指什么
  • 万盛集团网站建设seo软件
  • 谁可以做网站优化排名推广百度学术官网登录入口
  • 网站建设哪种语言好网站空间租用
  • 怎么在网站上打广告营销到底是干嘛的
  • 哈尔滨住房和城乡建设局网站首页常州网站关键词推广
  • 长春市长春网站建设怎么弄一个自己的网站
  • 怎么做网站百度经验石家庄seo外包的公司
  • 做网站哪个便宜站长工具源码
  • 平面设计公司有什么职位seo上首页
  • 郑州网站建设 推广百度关键词排名快速排名
  • 济南专门做网站的公司windows优化大师免费