热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

ssm(springmvc4+spring4+mybatis3)整合实战个人博客系统整合各大框架

ssm(springmvc4+spring4+mybatis3)整合实战-个人博客系统-整合各大框架  ssm框架整合开发实战,这一篇我将介绍如何实现各大框架的整合。  上一篇博客

ssm(springmvc4+spring4+mybatis3)整合实战-个人博客系统-整合各大框架

    ssm框架整合开发实战,这一篇我将介绍如何实现各大框架的整合。

    上一篇博客,我介绍了web.xml配置文件,那个文件是项目的核心配置文件,其中其实就包括了整合spring springmvc框架的配置。当然啦,该配置文件还有权限认证安全框架shiro的过滤器配置以及编码过滤器的配置。言归正传,下面就将各大框架的整合配置文件共享出来。

     首先是spring、springmvc的配置,spring框架的强大之处在此我就不多说了,起到的作用我就简单说几点吧。

1、其核心部分是IOC与AOP,前者即为所谓的控制反转,用于解决各大组件的依赖问题,也就是解耦的作用;AOP起到监视的作用,俗称面向切面,可以在事务开始前结束后做一层监视;

2、整合hibernate或者mybatis持久层框架,配置事务传播属性,在进行事务操作时起到很好的控制作用(commit,rollback等)。

3、springmvc是spring的一部分,提供的mvc编程模式大大提高了j2EE应用开发的高效性。。。

 

    下面介绍spring的配置applicationContext-spring.xml:

 


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:cOntext="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">


















































/login=anon
/admin/**=authc









































     加入jdbc配置jdbc.properties:

 

 

jdbc.driverClass=com.mysql.jdbc.Driver
jdbc.jdbcUrl=jdbc:mysql://localhost:3306/db_blog?useUnicode=true&characterEncoding=UTF-8
jdbc.username=root
jdbc.password=123456
#最大连接池数量
maxActive=10
#最小连接池数量
minIdle=2

    日志配置log4j.properties:

 

 

log4j.rootLogger=DEBUG, Console
#Console
log4j.appender.COnsole=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.COnversionPattern=%d [%t] %-5p [%c] - %m%n
log4j.logger.java.sql.ResultSet=INFO
log4j.logger.org.apache=INFO
log4j.logger.java.sql.COnnection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG

    mybatis配置文件mybatis-config.xml:

 

 


PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
spring-mvc.xml






    最后是springmvc的配置文件:

 

 


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:cOntext="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">


















    上面介绍的配置文件中:其实shiro的配置可以单独拿出来的(在这里我就偷懒了)。上面配置文件的内容我已经做了注释了,已看便可知。如果有问题,可以加入后面提供的群讨论。

 

     最后,当然是建立包结构,如下图,大伙就自己建 了:

《ssm(springmvc4+spring4+mybatis3)整合实战-个人博客系统-整合各大框架》

 

    最后,我就把本系统涉及的各个实体类的代码贴出来吧(其实就是JavaBean了,可以自己建表然后mybatis逆向工程自己生成–至于如何生成,可以看我的博客:mybatis逆向工程)

    首先是Blog.java:

 

package com.steadyjack.entity;
import java.io.Serializable;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
/**
* title:Blog.java
* description:博客实体
* time:2017年1月15日 下午9:22:23
* author:debug-steadyjack
*/
public class Blog implements Serializable {
private static final long serialVersiOnUID= 1L;

private Integer id; // 编号
private String title; // 博客标题
private String summary; // 摘要
private Date releaseDate; // 发布日期
private Integer clickHit; // 查看次数
private Integer replyHit; // 回复次数
private String content; // 博客内容
private String keyWord; // 关键字 空格隔开

private String contentNoTag; // 博客内容 无网页标签 (Lucene分词用)
private BlogType blogType; // 博客类型
private Integer blogCount; // 博客数量 非博客实际属性,主要是 根据发布日期归档查询博客数量用
private String releaseDateStr; // 发布日期字符串 只取年和月

private List imagesList=new LinkedList(); // 博客里存在的图片 主要用于前端列表展示显示缩略图

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 String getSummary() {
return summary;
}
public void setSummary(String summary) {
this.summary = summary;
}

public Date getReleaseDate() {
return releaseDate;
}
public void setReleaseDate(Date releaseDate) {
this.releaseDate = releaseDate;
}

public Integer getClickHit() {
return clickHit;
}
public void setClickHit(Integer clickHit) {
this.clickHit = clickHit;
}

public Integer getReplyHit() {
return replyHit;
}
public void setReplyHit(Integer replyHit) {
this.replyHit = replyHit;
}

public String getContent() {
return content;
}
public void setContent(String content) {
this.cOntent= content;
}

public String getContentNoTag() {
return contentNoTag;
}
public void setContentNoTag(String contentNoTag) {
this.cOntentNoTag= contentNoTag;
}

public BlogType getBlogType() {
return blogType;
}
public void setBlogType(BlogType blogType) {
this.blogType = blogType;
}

public Integer getBlogCount() {
return blogCount;
}
public void setBlogCount(Integer blogCount) {
this.blogCount = blogCount;
}

public String getReleaseDateStr() {
return releaseDateStr;
}
public void setReleaseDateStr(String releaseDateStr) {
this.releaseDateStr = releaseDateStr;
}

public String getKeyWord() {
return keyWord;
}
public void setKeyWord(String keyWord) {
this.keyWord = keyWord;
}

public List getImagesList() {
return imagesList;
}
public void setImagesList(List imagesList) {
this.imagesList = imagesList;
}

}

    然后是Blogger.java:

 

 

package com.steadyjack.entity;
/**
* title:Blogger.java
* description:博主实体
* time:2017年1月15日 下午9:25:23
* author:debug-steadyjack
*/
public class Blogger {
private Integer id; // 编号
private String userName; // 用户名
private String password; // 密码
private String nickName; // 昵称
private String sign; // 个性签名
private String proFile; // 个人简介
private String imageName; // 博主头像

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 getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}

public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}

public String getProFile() {
return proFile;
}
public void setProFile(String proFile) {
this.proFile = proFile;
}

public String getImageName() {
return imageName;
}
public void setImageName(String imageName) {
this.imageName = imageName;
}

}

    接着是BlogType.java:

 

 

package com.steadyjack.entity;
import java.io.Serializable;
/**
* title:BlogType.java
* description: 博客类型实体
* time:2017年1月15日 下午9:25:32
* author:debug-steadyjack
*/
public class BlogType implements Serializable{
/**
*
*/
private static final long serialVersiOnUID= 1L;

private Integer id; // 编号
private String typeName; // 博客类型名称
private Integer blogCount; // 数量
private Integer orderNo; // 排序 从小到大排序显示

public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}

public String getTypeName() {
return typeName;
}
public void setTypeName(String typeName) {
this.typeName = typeName;
}

public Integer getBlogCount() {
return blogCount;
}
public void setBlogCount(Integer blogCount) {
this.blogCount = blogCount;
}

public Integer getOrderNo() {
return orderNo;
}
public void setOrderNo(Integer orderNo) {
this.orderNo = orderNo;
}

}

    然后是Comment.java:

 

 

package com.steadyjack.entity;
import java.util.Date;
/**
* title:Comment.java
* description: 评论实体
* time:2017年1月15日 下午9:25:41
* author:debug-steadyjack
*/
public class Comment {
private Integer id; // 编号
private String userIp; // 用户IP
private String content; // 评论内容
private Blog blog; // 被评论的博客
private Date commentDate; // 评论日期
private Integer state; // 审核状态 0 待审核 1 审核通过 2 审核未通过

public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}

public String getUserIp() {
return userIp;
}
public void setUserIp(String userIp) {
this.userIp = userIp;
}

public String getContent() {
return content;
}
public void setContent(String content) {
this.cOntent= content;
}

public Blog getBlog() {
return blog;
}
public void setBlog(Blog blog) {
this.blog = blog;
}

public Date getCommentDate() {
return commentDate;
}
public void setCommentDate(Date commentDate) {
this.commentDate = commentDate;
}

public Integer getState() {
return state;
}
public void setState(Integer state) {
this.state = state;
}
}

   接着是Link.java:

 

 

package com.steadyjack.entity;
/**
* title:Link.java
* description:友情链接实体
* time:2017年1月15日 下午9:25:58
* author:debug-steadyjack
*/
public class Link {
private Integer id; // 编号
private String linkName; // 链接名称
private String linkUrl; // 链接地址
private Integer orderNo; // 排序序号 从小到大排序

public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}

public String getLinkName() {
return linkName;
}
public void setLinkName(String linkName) {
this.linkName = linkName;
}

public String getLinkUrl() {
return linkUrl;
}
public void setLinkUrl(String linkUrl) {
this.linkUrl = linkUrl;
}

public Integer getOrderNo() {
return orderNo;
}
public void setOrderNo(Integer orderNo) {
this.orderNo = orderNo;
}
}

    最后是PageBean.java:

 

 

package com.steadyjack.entity;
/**
* title:PageBean.java
* description:分页Model类
* time:2017年1月15日 下午9:26:23
* author:debug-steadyjack
*/
public class PageBean {
private int page; // 第几页
private int pageSize; // 每页记录数
private int start; // 起始页

public PageBean(int page, int pageSize) {
super();
this.page = page;
this.pageSize = pageSize;
}

public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}

public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getStart() {
return (page-1)*pageSize;
}
}

     具体各个实体的属性以及作用我都已经说清楚了!

 

 

     如果有相关问题:如想找我付费开发其他功能,讨论其中相关问题等等,可以来以下两群找我,我叫debug!

     Java开源技术交流:583522159    个人QQ:1948831260


推荐阅读
  • Android中高级面试必知必会,积累总结
    本文介绍了Android中高级面试的必知必会内容,并总结了相关经验。文章指出,如今的Android市场对开发人员的要求更高,需要更专业的人才。同时,文章还给出了针对Android岗位的职责和要求,并提供了简历突出的建议。 ... [详细]
  • Centos7.6安装Gitlab教程及注意事项
    本文介绍了在Centos7.6系统下安装Gitlab的详细教程,并提供了一些注意事项。教程包括查看系统版本、安装必要的软件包、配置防火墙等步骤。同时,还强调了使用阿里云服务器时的特殊配置需求,以及建议至少4GB的可用RAM来运行GitLab。 ... [详细]
  • Voicewo在线语音识别转换jQuery插件的特点和示例
    本文介绍了一款名为Voicewo的在线语音识别转换jQuery插件,该插件具有快速、架构、风格、扩展和兼容等特点,适合在互联网应用中使用。同时还提供了一个快速示例供开发人员参考。 ... [详细]
  • 本文介绍了Web学习历程记录中关于Tomcat的基本概念和配置。首先解释了Web静态Web资源和动态Web资源的概念,以及C/S架构和B/S架构的区别。然后介绍了常见的Web服务器,包括Weblogic、WebSphere和Tomcat。接着详细讲解了Tomcat的虚拟主机、web应用和虚拟路径映射的概念和配置过程。最后简要介绍了http协议的作用。本文内容详实,适合初学者了解Tomcat的基础知识。 ... [详细]
  • 本文介绍了南邮ctf-web的writeup,包括签到题和md5 collision。在CTF比赛和渗透测试中,可以通过查看源代码、代码注释、页面隐藏元素、超链接和HTTP响应头部来寻找flag或提示信息。利用PHP弱类型,可以发现md5('QNKCDZO')='0e830400451993494058024219903391'和md5('240610708')='0e462097431906509019562988736854'。 ... [详细]
  • Java序列化对象传给PHP的方法及原理解析
    本文介绍了Java序列化对象传给PHP的方法及原理,包括Java对象传递的方式、序列化的方式、PHP中的序列化用法介绍、Java是否能反序列化PHP的数据、Java序列化的原理以及解决Java序列化中的问题。同时还解释了序列化的概念和作用,以及代码执行序列化所需要的权限。最后指出,序列化会将对象实例的所有字段都进行序列化,使得数据能够被表示为实例的序列化数据,但只有能够解释该格式的代码才能够确定数据的内容。 ... [详细]
  • t-io 2.0.0发布-法网天眼第一版的回顾和更新说明
    本文回顾了t-io 1.x版本的工程结构和性能数据,并介绍了t-io在码云上的成绩和用户反馈。同时,还提到了@openSeLi同学发布的t-io 30W长连接并发压力测试报告。最后,详细介绍了t-io 2.0.0版本的更新内容,包括更简洁的使用方式和内置的httpsession功能。 ... [详细]
  • 图解redis的持久化存储机制RDB和AOF的原理和优缺点
    本文通过图解的方式介绍了redis的持久化存储机制RDB和AOF的原理和优缺点。RDB是将redis内存中的数据保存为快照文件,恢复速度较快但不支持拉链式快照。AOF是将操作日志保存到磁盘,实时存储数据但恢复速度较慢。文章详细分析了两种机制的优缺点,帮助读者更好地理解redis的持久化存储策略。 ... [详细]
  • 《数据结构》学习笔记3——串匹配算法性能评估
    本文主要讨论串匹配算法的性能评估,包括模式匹配、字符种类数量、算法复杂度等内容。通过借助C++中的头文件和库,可以实现对串的匹配操作。其中蛮力算法的复杂度为O(m*n),通过随机取出长度为m的子串作为模式P,在文本T中进行匹配,统计平均复杂度。对于成功和失败的匹配分别进行测试,分析其平均复杂度。详情请参考相关学习资源。 ... [详细]
  • 本文介绍了作者在开发过程中遇到的问题,即播放框架内容安全策略设置不起作用的错误。作者通过使用编译时依赖注入的方式解决了这个问题,并分享了解决方案。文章详细描述了问题的出现情况、错误输出内容以及解决方案的具体步骤。如果你也遇到了类似的问题,本文可能对你有一定的参考价值。 ... [详细]
  • 本文介绍了Java的集合及其实现类,包括数据结构、抽象类和具体实现类的关系,详细介绍了List接口及其实现类ArrayList的基本操作和特点。文章通过提供相关参考文档和链接,帮助读者更好地理解和使用Java的集合类。 ... [详细]
  • 海马s5近光灯能否直接更换为H7?
    本文主要介绍了海马s5车型的近光灯是否可以直接更换为H7灯泡,并提供了完整的教程下载地址。此外,还详细讲解了DSP功能函数中的数据拷贝、数据填充和浮点数转换为定点数的相关内容。 ... [详细]
  • 如何查询zone下的表的信息
    本文介绍了如何通过TcaplusDB知识库查询zone下的表的信息。包括请求地址、GET请求参数说明、返回参数说明等内容。通过curl方法发起请求,并提供了请求示例。 ... [详细]
  • LVS实现负载均衡的原理LVS负载均衡负载均衡集群是LoadBalance集群。是一种将网络上的访问流量分布于各个节点,以降低服务器压力,更好的向客户端 ... [详细]
  • GSIOpenSSH PAM_USER 安全绕过漏洞
    漏洞名称:GSI-OpenSSHPAM_USER安全绕过漏洞CNNVD编号:CNNVD-201304-097发布时间:2013-04-09 ... [详细]
author-avatar
手机用户2502922415_737
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有