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

买的网站模板会影响多功能网站建设服务至上

买的网站模板会影响,多功能网站建设服务至上,漳州房产网,献县网站建设公司数据库表 数据库叫blog_gp1701 author表 数据 blog表 数据 comment表 数据 post表 数据 目录结构 jar包导入 先给对应的jar包导入 建立一个junit单元测试 配置文件 log4j.properties ### \u914D\u7F6E\u6839 ### log4j.rootLogger debug,console ,fileAppender,dailyRo… 数据库表 数据库叫blog_gp1701 author表 数据 blog表 数据 comment表 数据 post表 数据 目录结构 jar包导入 先给对应的jar包导入 建立一个junit单元测试 配置文件 log4j.properties ### \u914D\u7F6E\u6839 ### log4j.rootLogger debug,console ,fileAppender,dailyRollingFile,ROLLING_FILE,MAIL,DATABASE### \u8BBE\u7F6E\u8F93\u51FAsql\u7684\u7EA7\u522B\uFF0C\u5176\u4E2Dlogger\u540E\u9762\u7684\u5185\u5BB9\u5168\u90E8\u4E3Ajar\u5305\u4E2D\u6240\u5305\u542B\u7684\u5305\u540D ### log4j.logger.org.apachedubug log4j.logger.java.sql.Connectiondubug log4j.logger.java.sql.Statementdubug log4j.logger.java.sql.PreparedStatementdubug log4j.logger.java.sql.ResultSetdubug### \u914D\u7F6E\u8F93\u51FA\u5230\u63A7\u5236\u53F0 ### log4j.appender.console org.apache.log4j.ConsoleAppender log4j.appender.console.Target System.out log4j.appender.console.layout org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern %d{ABSOLUTE} %5p %c{1}:%L - %m%n mybatis-config.xml ?xml version1.0 encodingUTF-8? !DOCTYPE configuration PUBLIC -//mybatis.org//DTD Config 3.0//EN http://mybatis.org/dtd/mybatis-3-config.dtd configuration settingssetting nameuseGeneratedKeys valuetrue/ /settings typeAliasestypeAlias typecom.geyao.mybatis.pojo.Blog aliasBlog/typeAlias typecom.geyao.mybatis.pojo.Author aliasAuthor/typeAlias typecom.geyao.mybatis.pojo.Comment aliasComment/typeAlias typecom.geyao.mybatis.pojo.Post aliasPost/ /typeAliasesenvironments defaultdevelopmentenvironment iddevelopmenttransactionManager typeJDBC /!-- 配置数据库连接信息 --dataSource typePOOLEDproperty namedriver valuecom.mysql.cj.jdbc.Driver /property nameurl valuejdbc:mysql://localhost:3306/blog_gp1701?serverTimezoneGMT%2B8 /property nameusername valueroot /property namepassword value123 //dataSource/environment/environmentsmappers!-- 注册userMapper.xml文件 userMapper.xml位于me.gacl.mapping这个包下所以resource写成me/gacl/mapping/userMapper.xml--mapper resourcecom/geyao/mybatis/mapper/BlogMapper.xml/mapper resourcecom/geyao/mybatis/mapper/AuthorMapper.xml/mapper resourcecom/geyao/mybatis/mapper/PostMapper.xml/mapper resourcecom/geyao/mybatis/mapper/CommentMapper.xml//mappers /configurationcom.geyao.mybatis.mapper AuthorMapper package com.geyao.mybatis.mapper;import com.geyao.mybatis.pojo.Author; public interface AuthorMapper {Author selectAuthorById(Integer id); }BlogMapper package com.geyao.mybatis.mapper;import java.util.List;import com.geyao.mybatis.pojo.Blog;public interface BlogMapper {Blog selectBlogById(Integer id);ListBlog selectBlogList();ListBlog selectBlogListNested();}Comment.Maoper package com.geyao.mybatis.mapper;import java.util.List;import com.geyao.mybatis.pojo.Comment;public interface CommentMapper { ListComment selectCommentByPostId(Integer id); }PostMapper package com.geyao.mybatis.mapper;import com.geyao.mybatis.pojo.Post;public interface PostMapper {Post selectPostById(Integer id); }AuthorMapper.xml ?xml version1.0 encodingUTF-8 ? !DOCTYPE mapper PUBLIC -//mybatis.org//DTD Mapper 3.0//EN http://mybatis.org/dtd/mybatis-3-mapper.dtd !-- 为这个mapper指定一个唯一的namespacenamespace的值习惯上设置成包名sql映射文件名这样就能够保证namespace的值是唯一的 例如namespaceme.gacl.mapping.userMapper就是me.gacl.mapping(包名)userMapper(userMapper.xml文件去除后缀)-- mapper namespacecom.geyao.mybatis.mapper.AuthorMapperresultMap typeAuthor idauthorResultMapid columnid propertyid jdbcTypeINTEGER/id/resultMapselect idselectAuthorById parameterTypeint resultMapauthorResultMapselect * from author where id#{id}/select /mapperBlogMapper.xml ?xml version1.0 encodingUTF-8 ? !DOCTYPE mapper PUBLIC -//mybatis.org//DTD Mapper 3.0//EN http://mybatis.org/dtd/mybatis-3-mapper.dtd mapper namespacecom.geyao.mybatis.mapper.BlogMapperresultMap typeBlog idblogResultMapid columnid propertyid jdbcTypeINTEGER/id association propertyauthor columnauthor javaTypeAuthorselectcom.geyao.mybatis.mapper.AuthorMapper.selectAuthorById/association/resultMapselect idselectBlogById parameterTypeint resultMapblogResultMapselect * from Blog where id#{id}/selectselect idselectBlogList resultMapblogResultMapselect * from Blog /selectresultMap typeBlog idblogResultMapNestedid columnblog_id propertyid/idresult columnblog_title propertytitle/resultresult columnblog_state propertystate/resultresult columnblog_featured propertyfeatured/resultresult columnblog_style propertystyle/resultassociation columnblog_atuthor propertyauthor javaTypeAuthorid columnauthor_id propertyid/idresult columnauthor_username propertyusername/resultresult columnauthor_password propertypassword/resultresult columnauthor_email propertyemail/resultresult columnauthor_bio propertybio/resultresult columnblog_favouriteSection propertyfavouriteSection/resultresult columnblog_nickname propertynickname/resultresult columnblog_realname propertyrealname/result/association/resultMapselect idselectBlogListNested resultMapblogResultMapNestedSELECTb.id AS blog_id,b.title AS blog_title,b.author AS blog_author,b.state AS blog_state,b.featured AS blog_featured,b.style AS blog_style,a.id AS author_id,a.username AS author_username,a.password AS author_password,a.email AS author_email,a.bio AS author_bio,a.favouriteSection AS author_favouriteSection,a.nickname AS author_nickname,a.realname AS author_realnameFROM blog bLEFT JOIN author aON b.author a.id/select /mapperCommentMapper.xml ?xml version1.0 encodingUTF-8 ? !DOCTYPE mapper PUBLIC -//mybatis.org//DTD Mapper 3.0//EN http://mybatis.org/dtd/mybatis-3-mapper.dtd !-- 为这个mapper指定一个唯一的namespacenamespace的值习惯上设置成包名sql映射文件名这样就能够保证namespace的值是唯一的 例如namespaceme.gacl.mapping.userMapper就是me.gacl.mapping(包名)userMapper(userMapper.xml文件去除后缀)-- mapper namespacecom.geyao.mybatis.mapper.CommentMapperresultMap typeComment idcommentResultMapid columnid propertyid jdbcTypeINTEGER/id/resultMapselect idselectCommentByPostId parameterTypeint resultMapcommentResultMapselect * from comment where post_id#{postId}/selectselect idselectCommentById parameterTypeint resultMapcommentResultMapselect * from comment where id#{id}/select /mapper PostMapper.xml ?xml version1.0 encodingUTF-8 ? !DOCTYPE mapper PUBLIC -//mybatis.org//DTD Mapper 3.0//EN http://mybatis.org/dtd/mybatis-3-mapper.dtd !-- 为这个mapper指定一个唯一的namespacenamespace的值习惯上设置成包名sql映射文件名这样就能够保证namespace的值是唯一的 例如namespaceme.gacl.mapping.userMapper就是me.gacl.mapping(包名)userMapper(userMapper.xml文件去除后缀)-- mapper namespacecom.geyao.mybatis.mapper.PostMapperresultMap typePost idpostResultMapid columnid propertyid jdbcTypeINTEGER/idcollection propertycommentList columnid javaTypeArrayList ofTypeCommentselectcom.geyao.mybatis.mapper.CommentMapper.selectCommentByPostId/collection/resultMapselect idselectPostById parameterTypeint resultMappostResultMapselect * from post where id#{id}/select /mappercom.geyao.mybatis.pojo Author package com.geyao.mybatis.pojo;public class Author {private Integer id;private String username;private String password;private String email;private String bio;private String favouriteSection;private String nickname;private String realname;public Author() {super();}public Integer getId() {return id;}public void setId(Integer id) {this.id id;}public String getUsername() {return username;}public void setUsername(String username) {this.username username;}public String getPassword() {return password;}public void setPassword(String password) {this.password password;}public String getEmail() {return email;}public void setEmail(String email) {this.email email;}public String getBio() {return bio;}public void setBio(String bio) {this.bio bio;}public String getFavouriteSection() {return favouriteSection;}public void setFavouriteSection(String favouriteSection) {this.favouriteSection favouriteSection;}public String getNickname() {return nickname;}public void setNickname(String nickname) {this.nickname nickname;}public String getRealname() {return realname;}public void setRealname(String realname) {this.realname realname;}public Author(Integer id, String username, String password, String email, String bio, String favouriteSection,String nickname, String realname) {super();this.id id;this.username username;this.password password;this.email email;this.bio bio;this.favouriteSection favouriteSection;this.nickname nickname;this.realname realname;}Overridepublic String toString() {return Author [id id , username username , password password , email email , bio bio , favouriteSection favouriteSection , nickname nickname , realname realname ];}}Blog package com.geyao.mybatis.pojo;import java.io.Serializable;public class Blog implements Serializable {private static final long serialVersionUID 1L;private Integer id;private String title;private Author author;private String state;private boolean featured;private String style;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;}public Author getAuthor() {return author;}public void setAuthor(Author author) {this.author author;}public String getState() {return state;}public void setState(String state) {this.state state;}public boolean isFeatured() {return featured;}public void setFeatured(boolean featured) {this.featured featured;}public String getStyle() {return style;}public void setStyle(String style) {this.style style;}public static long getSerialversionuid() {return serialVersionUID;}Overridepublic String toString() {return Blog [id id , title title , author author , state state , featured featured , style style ]\n;}}Comment package com.geyao.mybatis.pojo;import java.util.Date;public class Comment {private Integer id;private String name;private String comment;private Date createOn;private Post post;private Author author;public Comment() {}public Comment(Integer id, String name, String comment, Date createOn, Post post, Author author) {super();this.id id;this.name name;this.comment comment;this.createOn createOn;this.post post;this.author author;}public Integer getId() {return id;}public void setId(Integer id) {this.id id;}public String getName() {return name;}public void setName(String name) {this.name name;}public String getComment() {return comment;}public void setComment(String comment) {this.comment comment;}public Date getCreateOn() {return createOn;}public void setCreateOn(Date createOn) {this.createOn createOn;}public Post getPost() {return post;}public void setPost(Post post) {this.post post;}public Author getAuthor() {return author;}public void setAuthor(Author author) {this.author author;}Overridepublic String toString() {return Comment [id id , name name , comment comment , createOn createOn , post post , author author ];}}Post package com.geyao.mybatis.pojo;import java.util.Date; import java.util.List;public class Post {private Integer id;private Author author;private Blog blog;private Date createOn;private String section;private String subject;private String draft;private String body;private Integer visit;private ListComment commentList;public Post(Integer id, Author author, Blog blog, Date createOn, String section, String subject, String draft,String body, Integer visit, ListComment commentList) {super();this.id id;this.author author;this.blog blog;this.createOn createOn;this.section section;this.subject subject;this.draft draft;this.body body;this.visit visit;this.commentList commentList;}public Post() {super();}public Integer getId() {return id;}public void setId(Integer id) {this.id id;}public Author getAuthor() {return author;}public void setAuthor(Author author) {this.author author;}public Blog getBlog() {return blog;}public void setBlog(Blog blog) {this.blog blog;}public Date getCreateOn() {return createOn;}public void setCreateOn(Date createOn) {this.createOn createOn;}public String getSection() {return section;}public void setSection(String section) {this.section section;}public String getSubject() {return subject;}public void setSubject(String subject) {this.subject subject;}public String getDraft() {return draft;}public void setDraft(String draft) {this.draft draft;}public String getBody() {return body;}public void setBody(String body) {this.body body;}public Integer getVisit() {return visit;}public void setVisit(Integer visit) {this.visit visit;}public ListComment getCommentList() {return commentList;}public void setCommentList(ListComment commentList) {this.commentList commentList;}Overridepublic String toString() {return Post [id id , author author , blog blog , createOn createOn , section section , subject subject , draft draft , body body , visit visit ];}}com.geyao.mybatis.util MybatisUtil package com.geyao.mybatis.util;import java.io.InputStream; import java.io.Reader;import org.apache.ibatis.io.Resources; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactoryBuilder;public class MyBatisUtil {private static SqlSessionFactory sqlSessionFactory null;static {try {InputStream in Resources.getResourceAsStream(mybatis-config.xml);sqlSessionFactory new SqlSessionFactoryBuilder().build(in);} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}}private MyBatisUtil() {}public static SqlSession getSqlSession() {return sqlSessionFactory.openSession();} }单元测试 com.geyao.mybatis.mapper PostMannerTest package com.geyao.mybatis.mapper;import org.apache.ibatis.session.SqlSession; import org.junit.Test;import com.geyao.mybatis.pojo.Blog; import com.geyao.mybatis.pojo.Post; import com.geyao.mybatis.util.MyBatisUtil;public class PostMapperTest {Testpublic void testSelectPost() {SqlSession session MyBatisUtil.getSqlSession();PostMapper postMapper session.getMapper(PostMapper.class);Post post postMapper.selectPostById(1);session.close();System.out.println(post);} }BlogMapperTest类 package com.geyao.mybatis.mapper;import java.util.List;import org.apache.ibatis.session.SqlSession; import org.junit.Test;import com.geyao.mybatis.pojo.Author; import com.geyao.mybatis.pojo.Blog; import com.geyao.mybatis.pojo.Post; import com.geyao.mybatis.util.MyBatisUtil;public class BlogMapperTest {Testpublic void testselectBlogListNested() {SqlSession session MyBatisUtil.getSqlSession();BlogMapper blogMapper session.getMapper(BlogMapper.class);ListBlog biogList blogMapper.selectBlogListNested();session.close();System.out.println(biogList);}}运行结果
http://www.pierceye.com/news/591103/

相关文章:

  • 个人怎么做贷款网站什么是网络营销产品
  • 网站你的后台管理系统用什么做外包公司与劳务派遣区别
  • 设计师资源网站价格低油耗低的车
  • 中山快速做网站服务wordpress建站ftp
  • 做酒类直供网站行吗网站seo检测报告
  • 南昌建站费用网站建设出错1004
  • 十堰做网站的公司阿里巴巴外贸网站论坛
  • 品牌网站建设代理网站建设公司易下拉软件
  • 移动网站模板响应式网站开发教程pdf
  • 怎么设计网站内容小程序seo帝搜软件sem880官网
  • 十堰秦楚网 十堰新闻门户网站wordpress 点赞 开启
  • 做外贸网站需要注意些什么手续安阳吧贴吧
  • 国外申请域名的网站百度标记号码认证平台
  • 专门做淘宝代运营的网站支付建设网站的费用什么科目
  • 天津企业设计网站建设建个网站做外贸
  • 申请永久网站空间wordpress论坛采集
  • 网站如何做竞价佛山新网站建设机构
  • 网站建设费可以一次性冲费用吗学校门户网站作用
  • 手机上怎么制作网站音乐网站如何建立
  • 新乡企业网站建设公司寮步东莞网站建设
  • wordpress中国网站排名如何加入广告联盟赚钱
  • 济宁网站建设培训学校wordpress导入表单
  • 做农产品交易网站阿里云已备案域名购买
  • 免费建站网站一级大录像不卡谁给我一个企业邮箱认证
  • 中国做网站东台做网站公司
  • 建设数据库网站需要哪些设备wordpress多功能主题 cosy
  • 苏州市郭巷建设局网站一家专门做鞋子的网站
  • 光明网站建设网站建设成果
  • 商业网站建设举例宝塔做两个网站6
  • 网站优化排名分享隐迅推前端开发入门培训