---
title: "给springside一剂强心剂，重新点燃SSH架构的热情"
author: "vv_1024"
date: "2010-02-08T13:10:43Z"
tags: ["Rails", "SSH", "数据结构", "项目管理", "领域模型"]
categories: ["企业架构"]
slug: "springside-ssh"
draft: false
lastmod: "2010-02-08T13:10:43Z"
id: 591383
url: "https://lovephoenix.iteye.com/blog/591383"
---

这是一个代码生成工具，绝不是重复发明轮子，我是在08年学 rails 的时候受到了启发，目前在java开源界，类似 rails 快速开发工具有很多，但他们都是为自己的框架系统服务的。而这个代码生成工具理论上可以根据 模板 + 领域模型 生成任何系统源码，而我们也只要把精力集中在编写领域模型中。为了大家比较容易理解，我以springside为模型，编写了模板，下面演示了一个简单的blog。

先建立一个空项目，把框架复制到项目中。结构如下：
![](http://dl.iteye.com/upload/attachment/204557/2ccf7d70-9c9c-389d-9cc5-180392b1c480.png)

项目的源码文件结构，典型的 SSH 架构，相信大家都已经烂熟于心了。
![](http://dl.iteye.com/upload/attachment/204561/27ae2ac8-6c48-3021-852c-c9253343c4b0.png)

下面是要编写的领域模型类，这里一共有9个类，其中有两个是父类，直接就贴上源码了。
![](http://dl.iteye.com/upload/attachment/204563/d077434e-59cb-3156-ad82-90c7249893ba.png)

![](http://dl.iteye.com/upload/attachment/204565/ce19f319-c3fa-378e-94eb-11a980ccb48e.png)

![](http://dl.iteye.com/upload/attachment/204567/0e320219-9e48-3666-8254-8ac60aa86478.png)

![](http://dl.iteye.com/upload/attachment/204569/a3f48a75-7f42-393c-b68d-e420b24abd24.png)

![](http://dl.iteye.com/upload/attachment/204571/78788578-6ae8-370c-bbcf-0d7ac394efac.png)

![](http://dl.iteye.com/upload/attachment/204573/21efc7d5-eecf-3e2f-ba90-b77d182d776b.png)

![](http://dl.iteye.com/upload/attachment/204575/4f7bfd96-ea8c-3e99-9e39-ed0427d65884.png)

![](http://dl.iteye.com/upload/attachment/204578/57ec5f4a-7ee1-35a7-824f-a014eb6be3fc.png)

![](http://dl.iteye.com/upload/attachment/204580/802f8d6c-da0e-38af-872b-7792b2b4b2de.png)

![](http://dl.iteye.com/upload/attachment/204582/8dbc51c3-acda-3fd1-85f7-af1085d3ab22.png)


下面是 web 目录结构，已经集成了权限管理
![](http://dl.iteye.com/upload/attachment/204584/2fa86fe5-4190-35c0-af68-23a9ed9ced11.png)

运行代码生成器，下面贴上部分源码：
![](http://dl.iteye.com/upload/attachment/204586/222f19eb-d3b4-3851-b878-664acd6d12e8.png)

生成结果日志
![](http://dl.iteye.com/upload/attachment/204588/3a0f1dfb-289c-333c-a44a-b7b14aa6df5f.png)

F5刷新项目，可以看到 dao service webservice action vo 包中都生成了源码文件。
![](http://dl.iteye.com/upload/attachment/204590/f3a4d8a0-5219-3698-b636-466dbd22af5c.png)

web 目录中也生成了 jsp 文件
![](http://dl.iteye.com/upload/attachment/204592/e259f920-281f-3336-9fcf-6d10eb7a37f4.png)

配置数据库
![](http://dl.iteye.com/upload/attachment/204594/9fa83b9d-0c02-3dd3-bc34-328cdb5a13ee.png)

发布项目，运行web服务器
![](http://dl.iteye.com/upload/attachment/204596/bedc5d65-05f0-3867-a673-37a6763fecc6.png)

查看数据，hibernate已经自动生成了数据库表结构，并导入了必须的用户权限信息
![](http://dl.iteye.com/upload/attachment/204600/2d18db14-e87e-3eea-aa3b-eea41341ca51.png)

访问网站
![](http://dl.iteye.com/upload/attachment/204602/63bb9912-2800-3b7a-a330-c7326539f032.png)

![](http://dl.iteye.com/upload/attachment/204604/fd67f48f-fa40-384d-b791-fcf5c77633bc.png)

![](http://dl.iteye.com/upload/attachment/204606/8f5e78e4-f5c6-3c91-8108-a27cd1b78467.png)

![](http://dl.iteye.com/upload/attachment/204608/92d12f01-f428-3021-a9a8-e85a8b4debfd.png)

![](http://dl.iteye.com/upload/attachment/204610/473cc6d3-6b6f-3e20-8132-bec3c1d08aff.png)


待续。。。