曾无好事来相访,赖尔高文一起予。这篇文章主要讲述ssh整合 applicationContext.xml 配置文件相关的知识,希望能为你提供帮助。
【ssh整合 applicationContext.xml 配置文件】
文章图片
< ?xml version="1.0" encoding="UTF-8"?>
< beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:jaxws="http://cxf.apache.org/jaxws"
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/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd
">
< context:property-placeholder location="classpath:db.properties"/>
< !-- 数据源 -->
< bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
< property name="driverClass" value="https://www.songbingjia.com/android/${jdbc.driverClass}"> < /property>
< property name="jdbcUrl" value="https://www.songbingjia.com/android/${jdbc.url}"> < /property>
< property name="user" value="https://www.songbingjia.com/android/${jdbc.user}"> < /property>
< property name="password" value="https://www.songbingjia.com/android/${jdbc.password}"> < /property>
< /bean>
< !-- spring整合hibernate提供sessionFactory -->
< !-- < bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
< property name="dataSource" ref="dataSource"> < /property>
也可以通过注入hibernate配置信息
< property name="hibernateProperties">
< props>
< prop key="hibernate.dialect"> org.hibernate.dialect.Oracle10gDialect< /prop>
< prop key="hibernate.hbm2ddl.auto"> update< /prop>
< prop key="hibernate.show_sql"> true< /prop>
< prop key="hibernate.format_sql"> true< /prop>
< /props>
< /property>
扫描jpa实体所在包
< property name="packagesToScan">
< value> com.itheima.bos.domain< /value>
< /property>
< /bean> -->
< !-- spring整合jpa -->
< bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
< property name="dataSource" ref="dataSource" />
< !-- 扫描实体包路径 -->
< property name="packagesToScan" value="https://www.songbingjia.com/android/com.itheima.bos.domain" />
< !-- 指定持久层提供者为Hibernate -->
< property name="persistenceProvider">
< bean class="org.hibernate.ejb.HibernatePersistence" />
< /property>
< property name="jpaVendorAdapter">
< bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
< !-- 自动建表 -->
< property name="generateDdl" value="https://www.songbingjia.com/android/true" />
< property name="showSql" value="https://www.songbingjia.com/android/true" />
< property name="database" value="https://www.songbingjia.com/android/ORACLE" />
< property name="databasePlatform" value="https://www.songbingjia.com/android/org.hibernate.dialect.Oracle10gDialect" />
< /bean>
< /property>
< property name="jpaDialect">
< bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
< /property>
< /bean>
< !-- 配置事务管理器 -->
< bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
< property name="entityManagerFactory" ref="entityManagerFactory"> < /property>
< /bean>
< !-- 注解方式管理事务 -->
< tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
< !-- spring-data整合jpa :解放dao层,扫描dao层包-->
< jpa:repositories base-package="com.itheima.bos.dao"> < /jpa:repositories>
< !-- 组件扫描,识别注解 -->
< context:component-scan base-package="com.itheima.bos"/>
< !-- 配置远程调用CRM客户端的对象 -->
< jaxws:client id="customerClient" address="http://192.168.48.50:9091/bos_crm/service/customer?wsdl"
serviceClass="com.itheima.bos.crm.service.CustomerService" >
< /jaxws:client>
< !-- 发布订单服务 -->
< bean id="orderService" class="com.itheima.bos.service.take_delivery.OrderServiceImpl" />
< !-- 配置cxf服务端对象 -->
< jaxws:server id="bos" address="/order">
< jaxws:serviceBean>
< ref bean="orderService"/>
< /jaxws:serviceBean>
< /jaxws:server>
< !-- shiro环境配置 -->
< !-- 配置realm对象 -->
< bean id="bosRealm" class="com.itheima.bos.realm.BosRealm"> < /bean>
< !-- 配置shiro安全管理器的对象 -->
< bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
< !-- 注入realm对象 -->
< property name="realm" ref="bosRealm"> < /property>
< !-- 注入缓存管理器 -->
< property name="cacheManager" ref="cacheManager"> < /property>
< /bean>
< !-- 配置ehcache缓存管理器对象 -->
< bean id="cacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
< !-- 注入ehcache配置文件:配置缓存策略 -->
< property name="cacheManagerConfigFile" value="https://www.songbingjia.com/android/classpath:ehcache.xml"> < /property>
< /bean>
< !-- 配置shiro过滤器工厂,用于管理权限 -->
< bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
< !-- 注入安全管理器 -->
< property name="securityManager" ref="securityManager"> < /property>
< !-- loginUrl属性用于url拦截授权时,若用户未登录而访问需要登录才能访问的资源时,跳转到后面配置的页面 -->
< property name="loginUrl" value="https://www.songbingjia.com/login.jsp"> < /property>
< !-- unauthotizedUrl属性用于url拦截授权时,若用户访问未得到授权的资源时,跳转到后面配置的页面 -->
< property name="unauthorizedUrl" value="https://www.songbingjia.com/unauthorized.jsp"> < /property>
< !-- 注入过滤器链 -->
< property name="filterChainDefinitions">
< value>
< !--
/**:表示多有请求
authc:表示认证通过才能访问
anon:匿名过滤器,不需要用户认证通过就能访问,常用于访问静态资源和登录界面及用于登录的方法
perms:权限过滤器,参数可以有多个,表示当前用户必须具有所有包含的权限才能访问对应的URL或者方法
roles:角色过滤器,参数可以有多个,表示当前用户必须具有所有包含的角色才能访问对应的URL或者方法
-->
/login.jsp=anon
/css/**=anon
/js/**=anon
/images/**=anon
/validatecode.jsp=anon
/userAction_login.action=anon
/pages/base/standard.jsp = perms["stanardard_page"]
/courierAction_delteBatch.action = perms["courier_delete"]
/courierAction_update.action = perms["courier_update"]
/courierAction_save.action = perms["courier_save"]
/courierAction_page.action = perms["courier_page"]
/**=authc
< /value>
< /property>
< /bean>
< !-- 使用注解的方式拦截授权,强制使用cglib代理,在service层使用shiro注解 -->
< bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator">
< property name="proxyTargetClass" value="https://www.songbingjia.com/android/true"> < /property>
< /bean>
< !-- 配置shiro的切面 -->
< bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor"> < /bean>
< /beans>
推荐阅读
- 安卓插件化与热修复的选型(转)
- Android 增量更新完全解析 是增量不是热修复(转)
- App 端接收不到手机短信验证
- Android Studio 运行找不到夜神模拟器
- Android Studio 第五十五期 - Studio3.0升级到gradle3.0.0后API失效方案
- Android Studio卡在refreshing gradle project的原因和快速解决办法
- App保持登录状态的常用方法
- APP测试之-网址
- 开发百万猪系统app