码迷,mamicode.com
首页 > 编程语言 > 详细

spring学习总结

时间:2016-02-14 11:42:07      阅读:247      评论:0      收藏:0      [点我收藏+]

标签:

在实战中学习,模仿博客园的部分功能。包括用户的注册,登陆;发表新随笔,阅读随笔;发表评论,以及定时任务等。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 + "]";
    }
}
User.java

 

spring学习总结

标签:

原文地址:http://www.cnblogs.com/everSeeker/p/5188840.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!