您的位置:首页 > 其它

2017.4.28 SSM框架搭建与配置

2017-04-28 13:50 295 查看

1.项目结构



2.配置文件

对配置文件进行总结:

pom.xml
web.xml
-> 配置web相关
-> 读取application*.xml
5     -> 读取logback.xml
applicationContext.xml 
->配置spring的主要信息
->读取sqlMapConfig.xml
->读取mapper.xml
->读取ehcache.xml
sqlMapConfig.xml
     ->配置mybatis相关
 mapper.xml
     ->mybatis的映射文件
ehcache.xml
     ->配置ehcache相关
applicationContext-rms.xml 
->配置项目相关
applicationContext-shiro.xml
     ->配置shiro相关


(1)pom.xml

<!--1 单元测试-->
junit
<!--2 spring相关依赖 为什么没有spring-beans?-->
<!--核心依赖-->
spring-core
spring-context
spring-context-support
<!--web相关-->
spring-web
spring-webmvc
<!--数据库相关-->
spring-jdbc
spring-tx
<!--redis相关-->
spring-data-redis
jedis
<!--3 mybatis-->
mybatis
mybatis-spring
<!--4 日志-->
slf4j-api
logback-classic
<!--5 JSON-->
fastjson
<!--6 数据库-->
<!--连接池-->
druid
<!--驱动-->
mysql-connector-java
postgresql
<!--7 apache工具-->
commons-beanutils
commons-lang
<!--8 shiro相关依赖-->
shiro-core
shiro-web
shiro-aspectj
shiro-spring
shiro-ehcache
shiro-quartz
<!--9 ehcache相关依赖-->
ehcache
<!--10 servlet-->
javax.servlet-api
<!--11 标签库-->
jstl
<!--12 jersey相关依赖-->
jersey-bundle
jersey-spring
<!-- 这里<exclusions>了spring的几个包,为什么?-->
spring-beans,spring-context,spring-core,spring-web,spring-aop
<!--13 不太明白作用的-->
aspectjweaver
javaee-api


(2)web.xml

<!--配置文件读取-->
contextConfigLocation:classpath*:/spring/**/applicationContext*.xml
     logbackConfigLocation:file:/usr/local/***/***/conf/logback.xml
 <!--监听器-->
LogbackConfigListener
ContextLoaderListener
<!--Servlet-->
RESTServlet
DruidStatView
<!--过滤器-->
CharacterEncodingFilter
<!--shiroFilter-->
DelegatingFilterProxy


(3)applicationContext.xml

<!--配置文件读取-->
<context:property-placeholder location=**/>

<!--支持注解-->
<context:annotation-config/>

<!--自动扫描的包,过滤被扫描的类-->
<context:component-scan base-package="******">
<context:exclude-filter> ***
<context:include-filter> ***

<!--dataSource;sqlSeesionFactory;sqlSessionTemplate-->
<bean id="dataSource">
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
dataSource
typeAliasesPackage
configLocation:classpath:resources/mybatis/sqlMapConfig.xml
     mapperLocation: classpath:sql/*.xml
 <bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
sqlSessionFactory

<!--通过自动扫描方式创建mapper bean-->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">

<!--事务管理-->
<tx:annotation-driven transaction-manager="transactionManager">
<bean id="transactionManager>
dataSource

<!--cache-->
<cache:annotation-driven cache-manager="cacheManager" proxy-target-class="false"/>
<bean id="ehcacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
configLocation:classpath:ehcache/ehcache.xml
 <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
cacheManager:ehcacheManager


(4)application-rms.xml

<!--国际化资源-->
<bean id="messageSource" class="com.baosight.common.message.XinsightResourceBundleMessageSource">


(5)application-shiro.xml

//todo

(6)ehcache.xml

<defaultCache>
<cache name="authorizationCache">
<cache name="authenticationCache">


(7)sqlMapConfig.xml

<configuration>
<!--除去environments节点(datasource和txmanager本来的位置),其他mybatis的属性都可以在这里设置-->
</configuration>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: