中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁(yè) > news >正文

網(wǎng)站關(guān)鍵詞快速排名軟件網(wǎng)絡(luò)運(yùn)營(yíng)師

網(wǎng)站關(guān)鍵詞快速排名軟件,網(wǎng)絡(luò)運(yùn)營(yíng)師,谷歌seo和百度seo的區(qū)別,百度云 免費(fèi) 網(wǎng)站主機(jī)整體就是mysql里存了一張表&#xff0c;然后在java程序里用mybatis把數(shù)據(jù)讀出來(lái)的一個(gè)簡(jiǎn)單示例。 庫(kù) blog里有一張表 article 整個(gè)項(xiàng)目就是增加了這3個(gè)文件 首先是mybatis-config.xml文件 <?xml version"1.0" encoding"UTF-8" ?> <!DOCTYPE c…

整體就是mysql里存了一張表,然后在java程序里用mybatis把數(shù)據(jù)讀出來(lái)的一個(gè)簡(jiǎn)單示例。

庫(kù) blog里有一張表 article

整個(gè)項(xiàng)目就是增加了這3個(gè)文件

首先是mybatis-config.xml文件

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configurationPUBLIC "-//mybatis.org//DTD Config 3.0//EN""http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration><environments default="development"><environment id="development"><transactionManager type="JDBC"/><dataSource type="POOLED"><property name="driver" value="com.mysql.cj.jdbc.Driver"/><property name="url" value="jdbc:mysql://localhost:3306/blog"/><property name="username" value="root"/><property name="password" value="123456"/></dataSource></environment></environments><!--寫(xiě)好的sql映射文件(EmployeeMapper.xml)注冊(cè)到全局配置文件(mybatis-config.xml)中--><mappers><mapper resource="ArticleMapper.xml"/></mappers>
</configuration>

然后是ArticleMapper.XML

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.mybatis.example.BlogMapper"><select id="selectArticle" resultType="org.example.po.Article">select * from article where id = #{id}</select>
</mapper>

然后是和數(shù)據(jù)庫(kù)存儲(chǔ)模型對(duì)應(yīng)的對(duì)象Article類(lèi)

package org.example.po;import java.util.Date;public class Article {private Integer id;private String title;private String desc;private Integer cate;private Date createdAt;private Date updatedAt;private String content;public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getTitle() {return title;}public void setTitle(String title) {this.title = title == null ? null : title.trim();}public String getDesc() {return desc;}public void setDesc(String desc) {this.desc = desc == null ? null : desc.trim();}public Integer getCate() {return cate;}public void setCate(Integer cate) {this.cate = cate;}public Date getCreatedAt() {return createdAt;}public void setCreatedAt(Date createdAt) {this.createdAt = createdAt;}public Date getUpdatedAt() {return updatedAt;}public void setUpdatedAt(Date updatedAt) {this.updatedAt = updatedAt;}public String getContent() {return content;}public void setContent(String content) {this.content = content == null ? null : content.trim();}
}

然后就是運(yùn)行類(lèi),main方法

package org.example;import com.google.gson.Gson;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.example.po.Article;import java.io.InputStream;public class Main {public static void main(String[] args) throws Exception {String resource="mybatis-config.xml";InputStream inputStream= Resources.getResourceAsStream(resource);SqlSessionFactory sqlSessionFactory=new SqlSessionFactoryBuilder().build(inputStream);SqlSession sqlSession=sqlSessionFactory.openSession();Article article=sqlSession.selectOne("selectArticle",1);Gson gson=new Gson();System.out.println("Hello world!");System.out.println(gson.toJson(article));}
}

最后把pom.XML也貼一下

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>org.example</groupId><artifactId>mybatis-study</artifactId><version>1.0-SNAPSHOT</version><properties><maven.compiler.source>14</maven.compiler.source><maven.compiler.target>14</maven.compiler.target><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties><dependencies><dependency><groupId>org.mybatis</groupId><artifactId>mybatis</artifactId><version>3.5.9</version></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.27</version></dependency><dependency><groupId>com.google.code.gson</groupId><artifactId>gson</artifactId><version>2.10</version></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.30</version></dependency></dependencies></project>

其他問(wèn)題可以參這個(gè)官方教程

mybatis – MyBatis 3 | XML 映射器

http://www.risenshineclean.com/news/56499.html

相關(guān)文章:

  • 怎么做自己的彩票網(wǎng)站現(xiàn)在有哪些網(wǎng)址
  • 網(wǎng)站空間免費(fèi) 優(yōu)幫云站長(zhǎng)工具seo綜合查詢(xún)?cè)趺搓P(guān)閉
  • python做網(wǎng)站入門(mén)武漢網(wǎng)站制作推廣
  • wordpress篩選插件seo優(yōu)化操作
  • 網(wǎng)站建設(shè)屬開(kāi)票核定稅種奉化首頁(yè)的關(guān)鍵詞優(yōu)化
  • 網(wǎng)站建設(shè)師hao123主頁(yè)
  • 網(wǎng)站如何做域名解析廣州競(jìng)價(jià)托管代運(yùn)營(yíng)
  • 做婚紗網(wǎng)站策劃方案線上營(yíng)銷(xiāo)策劃方案
  • 企業(yè)移動(dòng)網(wǎng)站品牌seo廠家電話
  • 網(wǎng)站建設(shè)三要素寧波seo教學(xué)
  • 中衛(wèi)網(wǎng)站建設(shè)報(bào)價(jià)網(wǎng)址收錄入口
  • 綏化網(wǎng)站建設(shè)站長(zhǎng)工具關(guān)鍵詞挖掘
  • 深圳品牌設(shè)計(jì)公司的發(fā)展怎么制作seo搜索優(yōu)化
  • 南昌net網(wǎng)站開(kāi)發(fā)深圳門(mén)戶(hù)網(wǎng)站
  • 百度關(guān)鍵詞seo推廣推廣關(guān)鍵詞如何優(yōu)化
  • 怎么做外匯返傭的網(wǎng)站推廣普通話活動(dòng)方案
  • 網(wǎng)站后臺(tái)搜索nba最新排行
  • 網(wǎng)站自動(dòng)答題腳本怎么做seo項(xiàng)目是什么
  • 網(wǎng)站備案信息變更百度指數(shù)在線查詢(xún)前100
  • 網(wǎng)站是怎么優(yōu)化的亞洲長(zhǎng)尾關(guān)鍵詞挖掘
  • 白銀網(wǎng)站建設(shè)網(wǎng)絡(luò)營(yíng)銷(xiāo)策劃書(shū)8000字
  • 網(wǎng)站制作長(zhǎng)沙百度指數(shù)如何提升
  • 網(wǎng)站留言如何做的seo網(wǎng)站編輯優(yōu)化招聘
  • 南陽(yáng)網(wǎng)站托管百度百度網(wǎng)址大全
  • 怎么給網(wǎng)站做鏈接屏蔽一個(gè)產(chǎn)品的宣傳和推廣方案
  • 全球最熱門(mén)網(wǎng)站關(guān)鍵對(duì)話
  • 貴陽(yáng)網(wǎng)站建設(shè)-中國(guó)互聯(lián)百度400電話
  • 讓人家做網(wǎng)站需要問(wèn)什么問(wèn)題網(wǎng)站模板源碼
  • 青島做網(wǎng)站的公司哪個(gè)比較好百度外鏈查詢(xún)工具
  • 網(wǎng)站高端建設(shè)智慧軟文