这期内容当中小编将会给大家带来有关使用Spring MVC 和Mybatis 如何构建一个高性能的web,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
项目结构:
是一个典型的Maven 项目 :
src/main/Java:存放java源文件
src/main/resources:存放程序资源、配置文件
src/test/java:存放测试代码文件
src/main/webapp:web根目录
pom.xml : maven项目配置文件,管理依赖,编译,打包
主要的后端架构:spring + Spring MVC + Mybatis + Apache Shiro
前端界面主要使用MetroNic 模板,
先看我们搭建完成,跑起来的效果,这样你才有兴趣看下去:
你可以 在github 上 checkout quick4j项目 查看 ,并跟下面步骤 来搭建:
强烈建议你,checkout https://github.com/Eliteams/quick4j ,在本地跑起来,再试着自己搭建框架
首先创建 maven 项目 ,用 idea 、eclipse 或 mvn 命令行都行
配置 pom.xml ,添加框架依赖
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.eliteams</groupId> <artifactId>quick4j</artifactId> <packaging>war</packaging> <version>1.0.0</version> <name>quick4j App</name> <url>https://github.com/starzou/quick4j</url> <build> <finalName>quick4j</finalName> <plugins> <!-- Mybatis generator代码生成插件 配置 --> <plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <version>${plugin.mybatis.generator}</version> <configuration> <configurationFile>${mybatis.generator.generatorConfig.xml}</configurationFile> <overwrite>true</overwrite> <verbose>true</verbose> </configuration> </plugin> <!--Maven编译插件 配置--> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>${plugin.maven-compiler}</version> <configuration> <source>${project.build.jdk}</source> <target>${project.build.jdk}</target> <encoding>${project.build.sourceEncoding}</encoding> </configuration> </plugin> </plugins> <!--配置Maven 对resource文件 过滤 --> <resources> <resource> <directory>src/main/resources</directory> <includes> <include>***.xml</include> </includes> <filtering>true</filtering> </resource> <resource> <directory>src/main/java</directory> <includes> <include>***.xml</include> </includes> <filtering>true</filtering> </resource> </resources> </build> <properties> <!-- base setting --> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.locales>zh_CN</project.build.locales> <project.build.jdk>1.7</project.build.jdk> <!-- plugin setting --> <mybatis.generator.generatorConfig.xml>${basedir}/src/test/resources/generatorConfig.xml</mybatis.generator.generatorConfig.xml> <mybatis.generator.generatorConfig.properties>file:///${basedir}/src/test/resources/generatorConfig.properties</mybatis.generator.generatorConfig.properties> <!-- plugin versions --> <plugin.mybatis.generator>1.3.1</plugin.mybatis.generator> <plugin.maven-compiler>3.1</plugin.maven-compiler> <!-- lib versions --> <junit.version>4.11</junit.version> <spring.version>4.0.2.RELEASE</spring.version> <mybatis.version>3.2.2</mybatis.version> <mybatis.spring.version>1.2.2</mybatis.spring.version> <mysql.connector.version>5.1.30</mysql.connector.version> <postgresql.version>9.1-901.jdbc4</postgresql.version> <slf4j.version>1.6.6</slf4j.version> <log4j.version>1.2.12</log4j.version> <httpclient.version>4.1.2</httpclient.version> <jackson.version>1.9.13</jackson.version> <c3p0.version>0.9.1.2</c3p0.version> <druid.version>1.0.5</druid.version> <tomcat.jdbc.version>7.0.53</tomcat.jdbc.version> <jstl.version>1.2</jstl.version> <google.collections.version>1.0</google.collections.version> <cglib.version>3.1</cglib.version> <shiro.version>1.2.3</shiro.version> <commons.fileupload.version>1.3.1</commons.fileupload.version> <commons.codec.version>1.9</commons.codec.version> <commons.net.version>3.3</commons.net.version> <aspectj.version>1.6.12</aspectj.version> <netty.version>4.0.18.Final</netty.version> <hibernate.validator.version>5.1.1.Final</hibernate.validator.version> </properties> <dependencies> <!-- junit --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit.version}</version> </dependency> <!-- springframe start --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-oxm</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>${spring.version}</version> </dependency> <!-- springframe end --> <!-- mybatis start--> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>${mybatis.version}</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>${mybatis.spring.version}</version> </dependency> <!--mybatis end--> <!-- mysql-connector --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql.connector.version}</version> </dependency> <!-- DruidDataSource --> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>${druid.version}</version> </dependency> <!-- jackson --> <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-mapper-asl</artifactId> <version>${jackson.version}</version> </dependency> <!-- log start --> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>${log4j.version}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>${slf4j.version}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>${slf4j.version}</version> </dependency> <!-- log end --> <!-- servlet api --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.0.1</version> <scope>provided</scope> </dependency> <!-- jstl --> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>${jstl.version}</version> </dependency> <!-- start apache --> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>${commons.fileupload.version}</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>${httpclient.version}</version> </dependency> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>${commons.codec.version}</version> </dependency> <dependency> <groupId>commons-net</groupId> <artifactId>commons-net</artifactId> <version>${commons.net.version}</version> </dependency> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.1.3</version> </dependency> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> <version>3.2.1</version> </dependency> <!-- end apache --> <!-- google --> <dependency> <groupId>com.google.collections</groupId> <artifactId>google-collections</artifactId> <version>${google.collections.version}</version> </dependency> <!-- cglib --> <dependency> <groupId>cglib</groupId> <artifactId>cglib-nodep</artifactId> <version>${cglib.version}</version> </dependency> <!-- shiro --> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-spring</artifactId> <version>${shiro.version}</version> </dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-ehcache</artifactId> <version>${shiro.version}</version> </dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-core</artifactId> <version>${shiro.version}</version> </dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-web</artifactId> <version>${shiro.version}</version> </dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-quartz</artifactId> <version>${shiro.version}</version> </dependency> <!-- aspectjweaver --> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>${aspectj.version}</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjrt</artifactId> <version>${aspectj.version}</version> </dependency> <!-- hibernate-validator --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>${hibernate.validator.version}</version> </dependency> <!-- netty --> <dependency> <groupId>io.netty</groupId> <artifactId>netty-all</artifactId> <version>${netty.version}</version> </dependency> <dependency> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-core</artifactId> <version>1.3.2</version> <type>jar</type> <scope>test</scope> </dependency> </dependencies> </project>
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
软考中级精品资料免费领
- 历年真题答案解析
- 备考技巧名师总结
- 高频考点精准押题
- 资料下载
- 历年真题
193.9 KB下载数265
191.63 KB下载数245
143.91 KB下载数1148
183.71 KB下载数642
644.84 KB下载数2756
相关文章
发现更多好内容- 如何在 Java 中向数据库添加一条数据?(java怎么向数据库添加一条数据)
- Uncomtrade数据库异地备份指南
- CORS 在微服务架构中的应用场景有哪些?(cors在微服务架构中的应用场景)
- 如何在 Java 中创建 Maven 项目?(java怎么创建maven项目)
- 如何高效使用Uncomtrade数据库进行查询
- Java 配置环境变量后如何进行使用操作?(java配置环境变量后如何使用)
- Java 中防止接口重复提交的方法有哪些?(java接口防止重复提交的方法是什么)
- 如何提高 Java Office 的性能?(java office 怎样提高性能 )
- Java 抽象工厂模式的优缺点有哪些?(java抽象工厂模式有哪些优缺点)
- 在 Java 中,charsequence 的具体用法究竟是什么?(java中charsequence的用法是什么)