设为首页 加入收藏

TOP

Spring+SpringMVC企业快速开发架构搭建(一)
2015-11-10 13:46:06 来源: 作者: 【 】 浏览:11
Tags:Spring SpringMVC 企业 快速 开发 架构 搭建

从2014年12月开始,一直在研究Spring的框架;并且在我们新的开发框架中得到应用;这篇文章记录了这段时间的成长记录,仅此先给共同成长的小白。


为了简单,我们选择使用maven来构建项目,通过maven可以控制引入jar的版本,大大简化了jar包的管理工作,废话不多说,创建一个项目


一、创建一个新项目


1、创建maven项目


2、选择 maven-archetype-webapp


3、填写groupId、artifactId、package


项目目录:



二、项目创建完成后修改默认的jdk、编译器等默认属性,我的项目选择的是jdk7


3、 引入Spring的jar


Xml代码



? UTF-8
? 3.2.12.RELEASE
? 3.0.1.5.taobaocode-SNAPSHOT
? 0.2.3
? 2.1_3
? 1.6.6
? 2.0
? 1.9.5
? 3.10.1
? 1.4.3
? 3.9.3
? 5.1.34
? 2.1.0
? 1.1
? 5.10.0
? 5.5.23
? 1.3.1
? 1.1.15
? 2.4
? 2.2.11
? 2.1
? 4.1.5
? 1.1.1
? 6.8.13
? 1.10.18
? 3.4.2
? 1.7
? 3.3.8
? 1.2
? utf-8
?

?
?
? ?junit
? ?junit
? ?4.11
? ?test
?

?
?
? ?jstl
? ?jstl
? ?${jstl.version}
?

?
?
?
? ?org.springframework
? ?spring-web
? ?${spring.version}
?

?
? ?org.springframework
? ?spring-webmvc
? ?${spring.version}
?

?
? ?org.springframework
? ?spring-orm
? ?${spring.version}
?

?
? ?org.springframework
? ?spring-beans
? ?${spring.version}
?

?
? ?org.springframework
? ?spring-jms
? ?${spring.version}
?

?
? ?org.springframework
? ?spring-context-support
? ?${spring.version}
?

?
? ?org.aspectj
? ?aspectjweaver
? ?${aspectj.version}
?

?
? ?javax.jms
? ?javax.jms-api
? ?${jms.version}
?

?
? ?javax.mail
? ?mailapi
? ?${mail.version}
?


?
?
? ?com.alibaba
? ?fastjson
? ?${fastjson.version}
?

?
? ?net.sf.json-lib
? ?json-lib
? ?${json-lib.version}
? ?jdk15
?


?
?
? ?org.apache.activemq
? ?activemq-all
? ?${activemq.version}
?

?
? ?tomcat
? ?servlet-api
? ?${servlet-api.version}
?


?
?
? ?com.atomikos
? ?transactions-jta
? ?${atomikos.version}
? ?true
?

?
? ?com.atomikos
? ?transactions-jdbc
? ?${atomikos.version}
? ?true
?

?
? ?javax.transaction
? ?jta
? ?${jta.version}
? ?true
?

?
? ?com.alibaba
? ?druid
? ?1.0.9
? ?true
?


?
?
? ?org.apache.poi
? ?poi
? ?${poi.version}
?

?
? ?org.apache.poi
? ?poi-ooxml
? ?${poi.version}
?


?
?
? ?org.codehaus.jackson
? ?jackson-mapper-asl
? ?${jackson.version}
?

? ? ? ?
? ? ? ? ? cglib
? ? ? ? ? cglib-nodep
? ? ? ? ? ${cglib.version}
? ? ?

?
? commons-fileupload
? commons-fileupload
? ${fileupload.version}
?
? ?
?
? org.jodd
? jodd
? ${jodd.version}
?


四、 创建Spring的配置文件


1、 启动Spring需要在web.xml中配置监听,使用SpringMVC需要配置Spring的servlet


Web.xml代码




?Archetype Created Web Application
?
? java.lang.Throwable
? /500.jsp
?

?
? 500
? /500.jsp
?

?
? 404
? /404.jsp
?

?
?
? org.springframework.web.context.ContextLoaderListener
?

?

?
? contextConfigLocation
? classpath:applicationContext*.xml
?

?
? ? ? ? org.springframework.web.util.Log4jConfigListener
? ?

?
?
? springMVC
? org.springframework.web.servlet.DispatcherServlet
?
? ?Spring MVC Configuration Location
? ?contextConfigLocation
? ?
? ? classpath:spring-*.xml
? ?

?

? 1
?

?
? springMVC
? *.do
?

?
? encode
? org.springframework.web.filter.DelegatingFilterProxy
?

?

?
? ssojcFilter
? /*
?


2、Spring上下文配置文件ApplicationContext.xml用于配置Spring的通用配置


Applicationcontext.xml代码



?xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
?xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
?xmlns:context="http://www.springframework.org/schema/context"
?xsi:schemaLocation="http://www.springframework.org/schema/beans
? http://www.springframework.org/schema/beans/spring-beans.xsd
? http://www.springframework.org/schema/context
? http://www.springframework.org/schema/context/spring-context.xsd
? http://www.springframework.org/schema/aop
? http://www.springframework.org/schema/aop

首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Spring声明式事务管理 下一篇WebSocket使用示例

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: