这篇博客其实很早就应该写,早在半年前,因为对SpringMVC感兴趣,便自学了一下Spring。一段时间的学习后,对Spring有了一个基本的了解,于是想着自己动手搭建一个SpringMvc的框架出来。搭建的过程中遇到了很多的问题,其实在网上有许多的SpringMvc的框架搭建教程,但使用那些教程搭建起来的框架往往有或多或少的问题,如jar包下载不完全、log日志无法使用等,经历了一段时间的尝试后终于将框架搭建了起来。

在搭建起来后就想着自己写一篇博客记录一下,以便日后需要的时候方便查找。

在这里,我使用的工具有:maven3.3.3、Eclipse luna、mysql 5、tomcat 8.0,使用的Spring为4.2版本

由于在框架的搭建过程中会使用到一些数据,所以在搭建框架前,首先将数据库设计好。下面是我从网上获取的一个数据库文件,将其导入mysql数据库中即可:

ebuy.sql

-- MySQL dump 10.13  Distrib 5.6.25, for Win64 (x86_64)
--
-- Host: localhost Database: ebuy
-- ------------------------------------------------------
-- Server version 5.6.25 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; --
-- Table structure for table `firstsort`
-- DROP TABLE IF EXISTS `firstsort`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `firstsort` (
`fid` int(11) NOT NULL AUTO_INCREMENT,
`fname` varchar(20) NOT NULL,
PRIMARY KEY (`fid`)
) ENGINE=InnoDB DEFAULT CHARSET=gbk;
/*!40101 SET character_set_client = @saved_cs_client */; --
-- Dumping data for table `firstsort`
-- LOCK TABLES `firstsort` WRITE;
/*!40000 ALTER TABLE `firstsort` DISABLE KEYS */;
/*!40000 ALTER TABLE `firstsort` ENABLE KEYS */;
UNLOCK TABLES; --
-- Table structure for table `goods`
-- DROP TABLE IF EXISTS `goods`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `goods` (
`gid` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL,
`description` varchar(50) NOT NULL,
`image` varchar(100) NOT NULL,
`alive` varchar(2) DEFAULT NULL,
`recommend` varchar(1) DEFAULT NULL,
`addtime` date DEFAULT NULL,
`sid` int(11) NOT NULL,
PRIMARY KEY (`gid`)
) ENGINE=InnoDB DEFAULT CHARSET=gbk;
/*!40101 SET character_set_client = @saved_cs_client */; --
-- Dumping data for table `goods`
-- LOCK TABLES `goods` WRITE;
/*!40000 ALTER TABLE `goods` DISABLE KEYS */;
/*!40000 ALTER TABLE `goods` ENABLE KEYS */;
UNLOCK TABLES; --
-- Table structure for table `leaveword`
-- DROP TABLE IF EXISTS `leaveword`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `leaveword` (
`lid` int(11) NOT NULL AUTO_INCREMENT,
`message` varchar(100) NOT NULL,
`name` varchar(20) NOT NULL,
`riqi` date NOT NULL,
`gid` int(11) NOT NULL,
PRIMARY KEY (`lid`)
) ENGINE=InnoDB DEFAULT CHARSET=gbk;
/*!40101 SET character_set_client = @saved_cs_client */; --
-- Dumping data for table `leaveword`
-- LOCK TABLES `leaveword` WRITE;
/*!40000 ALTER TABLE `leaveword` DISABLE KEYS */;
/*!40000 ALTER TABLE `leaveword` ENABLE KEYS */;
UNLOCK TABLES; --
-- Table structure for table `manager`
-- DROP TABLE IF EXISTS `manager`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `manager` (
`mid` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL,
`password` varchar(20) NOT NULL,
PRIMARY KEY (`mid`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=gbk;
/*!40101 SET character_set_client = @saved_cs_client */; --
-- Dumping data for table `manager`
-- LOCK TABLES `manager` WRITE;
/*!40000 ALTER TABLE `manager` DISABLE KEYS */;
INSERT INTO `manager` VALUES (1,'superadmin','');
/*!40000 ALTER TABLE `manager` ENABLE KEYS */;
UNLOCK TABLES; --
-- Table structure for table `middle`
-- DROP TABLE IF EXISTS `middle`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `middle` (
`mid` int(11) NOT NULL,
`pid` int(11) NOT NULL,
PRIMARY KEY (`mid`,`pid`)
) ENGINE=InnoDB DEFAULT CHARSET=gbk;
/*!40101 SET character_set_client = @saved_cs_client */; --
-- Dumping data for table `middle`
-- LOCK TABLES `middle` WRITE;
/*!40000 ALTER TABLE `middle` DISABLE KEYS */;
INSERT INTO `middle` VALUES (1,1),(1,2),(1,3),(1,4),(1,5);
/*!40000 ALTER TABLE `middle` ENABLE KEYS */;
UNLOCK TABLES; --
-- Table structure for table `news`
-- DROP TABLE IF EXISTS `news`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `news` (
`nid` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(50) NOT NULL,
`content` varchar(1000) NOT NULL,
`riqi` date NOT NULL,
PRIMARY KEY (`nid`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=gbk;
/*!40101 SET character_set_client = @saved_cs_client */; --
-- Dumping data for table `news`
-- LOCK TABLES `news` WRITE;
/*!40000 ALTER TABLE `news` DISABLE KEYS */;
INSERT INTO `news` VALUES (1,'索爱W8 真正的Walkman Android音乐手机','一直传闻索爱发布Walkman加上Android的手机,这次终于成真了--索爱W8正式发布。索爱W8不但是Walkman品牌的音乐手机,也是Android 2.1版系统智能手机,提供有蓝色、红色、橙色三种颜色。','2011-04-23'),(2,'尼康D5100 新一代可翻转LCD的中端数码单反','虽然日本地震影响了不少3C厂商的新品发布计划,但尼康最近依然推出最新一代中端数码单反D5100。这款尼康D5100十分给力,带有3英寸的可翻转的大屏幕LCD,若含AF-S DX Zoom-NIKKOR 18-55mm f/3.5-5.6G ED VR镜头,套机售价约899美元。','2011-04-13'),(3,'iPad降价!价格暴跌到2888元','随着iPad 2的上市,旧款iPad开始降价促销,清理库存。虽然,iPad 2在国内上市时间没有公布,或许遇到某些问题,也因此未来较长时间还是只会继续销售iPad了。但庆幸的是,iPad降价没有漏到,iPad一代WIFI 16GB版本价格暴跌到2888元人民币,即便是3G版本的iPad价格也不过是3888元人民币,简直就是横扫千军,相信就算是旧款iPad,也会买断市了。','2011-03-03'),(4,'NEC N-04C 7.7mm的全球最薄手机','NEC最近在日本发布了一款拥有全球最薄称号的手机,型号就是NEC N-04C,这款全球最薄手机拥有7.7mm的机身,而且是预装Andorid操作系统,相信凭着如此性感的身材,必然能俘获不少的时尚粉丝。','2011-02-20'),(5,'摩托罗拉XOOM 首款平板电脑登场','摩托罗拉最近正式推出了首款平板电脑“MOTO XOOM”,一发布就获得了媒体极大的聚焦。作为摩托罗拉的第一款平板电脑,摩托罗拉XOOM预装了最新的Android 3.0操作系统,3G/4G版本售价为799美元,而WiFi版本,不支持3G网络的Xoom售价为600美元。','2011-03-03'),(6,'创新ZEN Touch 2 内置Android系统的播放器','Android系统越来越受追捧,创新就将Android系统引入到旗下的播放器中,推出了新款创新ZEN Touch 2,就是采用了Android 2.1系统,有8GB和16GB容量,售价约1600元','2010-12-10');
/*!40000 ALTER TABLE `news` ENABLE KEYS */;
UNLOCK TABLES; --
-- Table structure for table `orders`
-- DROP TABLE IF EXISTS `orders`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `orders` (
`oid` int(11) NOT NULL,
`ostate` varchar(1) NOT NULL,
`name` varchar(20) NOT NULL,
`address` varchar(50) NOT NULL,
`tel` varchar(20) NOT NULL,
`paytype` varchar(8) NOT NULL,
`riqi` date NOT NULL,
`money` double(10,3) NOT NULL,
`userid` int(11) NOT NULL,
PRIMARY KEY (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=gbk;
/*!40101 SET character_set_client = @saved_cs_client */; --
-- Dumping data for table `orders`
-- LOCK TABLES `orders` WRITE;
/*!40000 ALTER TABLE `orders` DISABLE KEYS */;
/*!40000 ALTER TABLE `orders` ENABLE KEYS */;
UNLOCK TABLES; --
-- Table structure for table `placard`
-- DROP TABLE IF EXISTS `placard`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `placard` (
`placardid` int(11) NOT NULL AUTO_INCREMENT,
`messages` varchar(300) NOT NULL,
`riqi` date NOT NULL,
PRIMARY KEY (`placardid`)
) ENGINE=InnoDB DEFAULT CHARSET=gbk;
/*!40101 SET character_set_client = @saved_cs_client */; --
-- Dumping data for table `placard`
-- LOCK TABLES `placard` WRITE;
/*!40000 ALTER TABLE `placard` DISABLE KEYS */;
/*!40000 ALTER TABLE `placard` ENABLE KEYS */;
UNLOCK TABLES; --
-- Table structure for table `purview`
-- DROP TABLE IF EXISTS `purview`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `purview` (
`pid` int(11) NOT NULL AUTO_INCREMENT,
`purview` char(1) NOT NULL,
PRIMARY KEY (`pid`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=gbk;
/*!40101 SET character_set_client = @saved_cs_client */; --
-- Dumping data for table `purview`
-- LOCK TABLES `purview` WRITE;
/*!40000 ALTER TABLE `purview` DISABLE KEYS */;
INSERT INTO `purview` VALUES (1,''),(2,''),(3,''),(4,''),(5,'');
/*!40000 ALTER TABLE `purview` ENABLE KEYS */;
UNLOCK TABLES; --
-- Table structure for table `sale`
-- DROP TABLE IF EXISTS `sale`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `sale` (
`saleid` int(11) NOT NULL AUTO_INCREMENT,
`gid` int(11) NOT NULL,
`scount` int(11) NOT NULL,
`oid` int(11) NOT NULL,
`saleprice` double(10,3) NOT NULL,
`state` char(1) NOT NULL,
`riqi` date NOT NULL,
PRIMARY KEY (`saleid`)
) ENGINE=InnoDB DEFAULT CHARSET=gbk;
/*!40101 SET character_set_client = @saved_cs_client */; --
-- Dumping data for table `sale`
-- LOCK TABLES `sale` WRITE;
/*!40000 ALTER TABLE `sale` DISABLE KEYS */;
/*!40000 ALTER TABLE `sale` ENABLE KEYS */;
UNLOCK TABLES; --
-- Table structure for table `secondsort`
-- DROP TABLE IF EXISTS `secondsort`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `secondsort` (
`sid` int(11) NOT NULL AUTO_INCREMENT,
`sname` varchar(20) NOT NULL,
`fid` int(11) NOT NULL,
PRIMARY KEY (`sid`)
) ENGINE=InnoDB DEFAULT CHARSET=gbk;
/*!40101 SET character_set_client = @saved_cs_client */; --
-- Dumping data for table `secondsort`
-- LOCK TABLES `secondsort` WRITE;
/*!40000 ALTER TABLE `secondsort` DISABLE KEYS */;
/*!40000 ALTER TABLE `secondsort` ENABLE KEYS */;
UNLOCK TABLES; --
-- Table structure for table `storage`
-- DROP TABLE IF EXISTS `storage`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `storage` (
`storageid` int(11) NOT NULL AUTO_INCREMENT,
`gid` int(11) NOT NULL,
`inprice` double(10,3) NOT NULL,
`outprice` double(10,3) NOT NULL,
`marketprice` double(10,3) NOT NULL,
`count` int(11) NOT NULL,
PRIMARY KEY (`storageid`)
) ENGINE=InnoDB DEFAULT CHARSET=gbk;
/*!40101 SET character_set_client = @saved_cs_client */; --
-- Dumping data for table `storage`
-- LOCK TABLES `storage` WRITE;
/*!40000 ALTER TABLE `storage` DISABLE KEYS */;
/*!40000 ALTER TABLE `storage` ENABLE KEYS */;
UNLOCK TABLES; --
-- Table structure for table `transfer`
-- DROP TABLE IF EXISTS `transfer`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `transfer` (
`tid` int(11) NOT NULL AUTO_INCREMENT,
`account` char(19) NOT NULL,
`password` char(6) NOT NULL,
`balance` double(10,3) NOT NULL,
PRIMARY KEY (`tid`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=gbk;
/*!40101 SET character_set_client = @saved_cs_client */; --
-- Dumping data for table `transfer`
-- LOCK TABLES `transfer` WRITE;
/*!40000 ALTER TABLE `transfer` DISABLE KEYS */;
INSERT INTO `transfer` VALUES (1,'','',10000.000),(2,'','',10000.000),(3,'','',10000.000);
/*!40000 ALTER TABLE `transfer` ENABLE KEYS */;
UNLOCK TABLES; --
-- Table structure for table `userinfo`
-- DROP TABLE IF EXISTS `userinfo`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `userinfo` (
`userid` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL,
`password` varchar(20) NOT NULL,
`question` varchar(30) NOT NULL,
`answer` varchar(30) NOT NULL,
`realname` varchar(20) DEFAULT NULL,
`sex` varchar(2) DEFAULT NULL,
`email` varchar(20) NOT NULL,
`id` char(18) NOT NULL,
`postalcode` varchar(6) DEFAULT NULL,
`address` varchar(30) DEFAULT NULL,
`tel` varchar(11) DEFAULT NULL,
`score` double(10,3) DEFAULT NULL,
PRIMARY KEY (`userid`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=gbk;
/*!40101 SET character_set_client = @saved_cs_client */; --
-- Dumping data for table `userinfo`
-- LOCK TABLES `userinfo` WRITE;
/*!40000 ALTER TABLE `userinfo` DISABLE KEYS */;
INSERT INTO `userinfo` VALUES (1,'ppp','','qqqqq','ddddd','rrrr','男','123@QQ.com','dd','dfdf','eeee','',123.100);
/*!40000 ALTER TABLE `userinfo` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; -- Dump completed on 2016-01-27 22:18:32

在该项目中,我是用的持久化工具是mybatis,而mybatis有一个工具(mybatis-generator-core-1.3.2),可以自动将数据库中的表映射成相对应的dao、model、model-db xml文件。

在使用该工具时,需要配置一份xml文件(generator.xml)以及一个数据库的驱动jar包

generator.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"> <generatorConfiguration>
<!-- 数据库驱动包位置 -->
<classPathEntry location="E:\JavaSmallTools\myBi\mysql-connector-java-5.1.26-bin.jar" /> <context id="DB2Tables" targetRuntime="MyBatis3"> <commentGenerator>
<property name="suppressDate" value="true" />
</commentGenerator> <!-- 数据库链接URL、用户名、密码 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost/ebuy" userId="root" password="123456">
</jdbcConnection> <javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver> <!-- 生成模型的包名和位置 -->
<javaModelGenerator targetPackage="com.welv.model"
targetProject="E:\JavaSmallTools\myBi\com">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator> <!-- 生成的映射文件包名和位置 -->
<sqlMapGenerator targetPackage="com.welv.mapping"
targetProject="E:\JavaSmallTools\myBi\com">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator> <!-- 生成DAO的包名和位置 -->
<javaClientGenerator type="XMLMAPPER"
targetPackage="com.welv.dao" targetProject="E:\JavaSmallTools\myBi\com">
<property name="enableSubPackages" value="true" />
</javaClientGenerator> <!-- 数据库中需要生成java代码的表的映射关系 -->
<table tableName="firstsort" domainObjectName="Firstsort" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> </table>
<table tableName="goods" domainObjectName="Goods" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> </table>
<table tableName="leaveword" domainObjectName="Leaveword" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> </table>
<table tableName="manager" domainObjectName="Manager" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> </table>
<table tableName="middle" domainObjectName="Middle" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> </table>
<table tableName="news" domainObjectName="News" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> </table>
<table tableName="orders" domainObjectName="Orders" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> </table>
<table tableName="placard" domainObjectName="Placard" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> </table>
<table tableName="purview" domainObjectName="Purview" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> </table>
<table tableName="sale" domainObjectName="Sale" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> </table>
<table tableName="secondsort" domainObjectName="Secondsort" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> </table>
<table tableName="transfer" domainObjectName="Transfer" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> </table>
<table tableName="userinfo" domainObjectName="Userinfo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> </table>
<table tableName="storage" domainObjectName="Storage" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> </table> </context>
</generatorConfiguration>

在该文件中,主要分为5部分,每部分的内容基本上在文件中都有说明,值得注意的是第五部分,也就是各个表的映射关系部分中,将大部分的值都赋false,其原因是,如果为true则会产生大量的无用文件,以及有用文件中产生大量的无用代码,全部使用false有利于generate clean code,便于后期的维护。

在修改完generator.xml文件后,将文件和工具(mybatis-generator-core-1.3.2)放在同一目录下。使用cmd命令,cd到该文件夹下,输入命令:

   java -jar mybatis-generator-core-1.3.2.jar -configfile generator.xml -overwrite

命令执行完后,打开预先设置好的文件夹,可看到一下目录:

从该目录中可看出,dao、mapping、model都已经生成,并且通过该工具生成的代码,其依赖关系也已经关联好,不需要在修改。

值得注意的是,通过该方式生成的dao文件均为interface,即接口类型。而具体的sql实现均在mapping的xml文件中实现,并且在生成的dao中只包含基本的增删改查,所以很多的方法需要自己添加,而添加新的方法需要在dao和mapping中同时进行修改。

至此,基本的持久化层代码已经生成,留在以便待用,接下去便可以开始搭建框架了。

Spring4 mvc+maven 框架搭建(1)的更多相关文章

  1. Spring4 mvc+maven 框架搭建(3)

    经过前面两个环节,spring mvc的原料已经准备好了,现在就可以正式开始搭建springmvc框架了. 首先先介绍介绍搭建的框架具有的功能: 1)集成log4j,配置好日志相关并可以打印出相关的日 ...

  2. Spring4 mvc+maven 框架搭建(2)

    在上一篇博客中,数据库数据和mybatis相关的java代码已经生成,接下来就可以使用IDE工具来搭建框架了. 在这里,我使用maven构建和管理代码,使用jdk1.8环境. 首先打开Eclipse, ...

  3. (一)springmvc+spring+mybatis+maven框架搭建

    (一)springmvc+spring+mybatis+maven框架搭建 1.说明 工作之余,为了学习点东西.先搭建个框架. 以后要往里面加东西,比如rabbitMQ.redis.shiro等. 也 ...

  4. Spring MVC + jpa框架搭建,及全面分析

    一,hibernate与jpa的关系 首先明确一点jpa是什么?以前我就搞不清楚jpa和hibernate的关系. 1,JPA(Java Persistence API)是Sun官方提出的Java持久 ...

  5. SSM+Redis+Shiro+Maven框架搭建及集成应用

    引文: 本文主要讲述项目框架搭建时的一些简单的使用配置,教你如何快速进行项目框架搭建. 技术: Spring+SpringMVC+Mybatis+Redis+Shiro+Maven          ...

  6. 从零开始--Spring项目整合(1)使用maven框架搭建项目

    这些年一直在用spring的框架搭建项目,现在开始我们从零开始利用Spring框架来搭建项目,目前我能想到有Spring.SpringMVC.SpringJDBC.Mybatis.WebSockt.R ...

  7. spring4+hibernate4+maven环境搭建

    本文主要介绍利用maven搭建spring4+hibernate4开发环境. 首先我们创建一个maven项目,具体步骤就不详细介绍了,看看我们pom.xml文件 <project xmlns=& ...

  8. Spring MVC Maven 环境搭建与部署

    本文简单演示了本地开发环境的搭建.项目出包.部署运行.HelloWorld,以及部分注意事项. 起初的玩法:先安装Eclipse,然后分别下载并安装Maven.spring的插件,再进行工程模式转换, ...

  9. Spring+Spring MVC+Hibernate框架搭建实例

    前言:这里只是说明整个搭建流程,并不进行原理性的讲解 一 下面所需要用到的数据库配置: 数据库方面,使用mysql创建一个users表,具体代码如下: 1 2 3 4 5 6 7 8 9 10 11 ...

随机推荐

  1. Calendar 得到前一天当前时间

    @Test public void test(){ //因为Calendar的构造方法是私有的,所以实例化一个Calendar对象用getInstance方法 Calendar calendar = ...

  2. ArcGIS 关于Web_Mercator

    #小知识#EPSG,即 European Petroleum Standards Group 欧洲石油标准组织 在ArcGIS 10中Web Mercator有三种EPSG编号.他们分别是EPSG38 ...

  3. text 文本。

    //支持转义符"\".   <text/> 组件内只支持 <text/> 嵌套. //除了文本节点以外的其他节点都无法长按选中. <view clas ...

  4. git使用教程(初次配置+错误提示)

    初次使用配置目录:https://blog.csdn.net/Esc_Tab_End/article/details/84144063 error: RPC failed; curl 56 OpenS ...

  5. 【MySQL】死锁问题分析

    1.MySQL常用存储引擎的锁机制: MyISAM和MEMORY采用表级锁(table-level locking)   BDB采用页面锁(page-level locking)或表级锁,默认为页面锁 ...

  6. java 调用c++程序实例

    1.java程序: package com.zhangshitong; import java.io.File; public class Java2cpp { static{ System.load ...

  7. Swift简单实现一个常规条款、免责声明文字+带有链接的展示形式

    效果:   IMG_F08DABE063A6-1.jpeg class DisclamerView: UIView { //@objc weak var vc:UIViewController? // ...

  8. Python自动化开发 - Django【进阶篇】

    Model 到目前为止,当我们的程序涉及到数据库相关操作时,我们一般都会这么搞: 创建数据库,设计表结构和字段 使用 MySQLdb 来连接数据库,并编写数据访问层代码 业务逻辑层去调用数据访问层执行 ...

  9. mysql 唯一索引UNIQUE使用方法详解

    创建唯一索引的目的不是为了提高访问速度,而只是为了避免数据出现重复.唯一索引可以有多个但索引列的值必须唯一,索引列的值允许有空值.如果能确定某个数据列将只包含彼此各不相同的值,在为这个数据列创建索引的 ...

  10. Kali Linux渗透测试实战 1.1 Kali Linux简介

    1.1 Kali Linux简介 如果您之前使用过或者了解BackTrack系列Linux的话,那么我只需要简单的说,Kali是BackTrack的升级换代产品,从Kali开始,BackTrack将成 ...