spring学习总结
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring学习总结相关的知识,希望对你有一定的参考价值。
在实战中学习,模仿博客园的部分功能。包括用户的注册,登陆;发表新随笔,阅读随笔;发表评论,以及定时任务等。Entity层设计3张表,分别为user表(用户),essay表(随笔)以及comment表(评论)。表结构如下:
项目开发采用Intellij IDEA + maven,整个项目结构如下如下图所示:
下面开始详细介绍。
一、Mybatis
1、先做准备工作,在entity目录下创建与数据库中表对应的类,以user表为例。
package com.everSeeker.entity; import java.io.Serializable; /** * 对象的序列化 class implements Serializable * 参考文档:http://www.cnblogs.com/xudong-bupt/archive/2013/05/19/3086493.html */ public class User implements Serializable { private int id; private String username; private String password; private int score; private int ranking; private int essayCount; public User() {} public User(String username, String password) { this.username = username; this.password = password; score = 0; ranking = 0; essayCount = 0; } public int getId() { return id; } public void setId(int 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 int getScore() { return score; } public void setScore(int score) { this.score = score; } public int getRanking() { return ranking; } public void setRanking(int ranking) { this.ranking = ranking; } public int getEssayCount() { return essayCount; } public void setEssayCount(int essayCount) { this.essayCount = essayCount; } @Override public String toString() { return "User [id=" + id + ", username=" + username + ", password=" + password + ", score=" + score + ", rankding=" + ranking + ", essayCount=" + essayCount + "]"; } }
以上是关于spring学习总结的主要内容,如果未能解决你的问题,请参考以下文章