ssh中的application.xml配置

时人不识凌云木,直待凌云始道高。这篇文章主要讲述ssh中的application.xml配置相关的知识,希望能为你提供帮助。


关于mysql 的 jdbc.properties

1 jdbc.driverClassName=com.mysql.jdbc.Driver 2 jdbc.url=jdbc:mysql://localhost:3306/ue_project 3 jdbc.username=root 4 jdbc.password=huashow


ssh中的application.xml配置

1 < ?xml version="1.0" encoding="UTF-8"?> 2 < beans xmlns="http://www.springframework.org/schema/beans" 3xmlns:context="http://www.springframework.org/schema/context" 4xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 5xmlns:aop="http://www.springframework.org/schema/aop" 6xmlns:util="http://www.springframework.org/schema/util" 7xmlns:tx="http://www.springframework.org/schema/tx" 8xsi:schemaLocation=" 9http://www.springframework.org/schema/context 10http://www.springframework.org/schema/context/spring-context.xsd 11http://www.springframework.org/schema/beans 12http://www.springframework.org/schema/beans/spring-beans.xsd 13http://www.springframework.org/schema/aop 14http://www.springframework.org/schema/aop/spring-aop.xsd 15http://www.springframework.org/schema/util 16http://www.springframework.org/schema/util/spring-util.xsd 17http://www.springframework.org/schema/tx 18http://www.springframework.org/schema/tx/spring-tx.xsd 19"> 20< !-- 读取jdbc.properties配置文件 --> 21< bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 22< property name="locations" value="https://www.songbingjia.com/android/classpath:jdbc.properties"/> 23< /bean> 24< !-- 配置jdbc的dataSource--> 25< bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> 26< property name="driverClassName" value="https://www.songbingjia.com/android/${jdbc.driverClassName}"/> 27< property name="url" value="https://www.songbingjia.com/android/${jdbc.url}"> < /property> 28< property name="username" value="https://www.songbingjia.com/android/${jdbc.username}"> < /property> 29< property name="password" value="https://www.songbingjia.com/android/${jdbc.password}"> < /property> 30< /bean> 31< bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean"> 32< property name="dataSource"ref="dataSource"/> 33< property name="mappingResources"> 34< list> 35< value> /com/hnqy/entity/Admin.hbm.xml< /value> 36< value> /com/hnqy/entity/Figure.hbm.xml< /value> 37< value> /com/hnqy/entity/Goodsdetail.hbm.xml< /value> 38< value> /com/hnqy/entity/Ordermanager.hbm.xml< /value> 55< /list> 56< /property> 57< property name="hibernateProperties"> 58< value> 59hibernate.dialect=org.hibernate.dialect.MySQLDialect 60hibernate.show_sql=true 61hibernate.format_sql=true 62< /value> 63< /property> 64< /bean> 65< !-- 定义hiberntateTemplate所在的bean --> 66< bean name="hibernateTemplate" class="org.springframework.orm.hibernate5.HibernateTemplate"> 67< property name="sessionFactory" ref="sessionFactory"> < /property> 68< /bean> 69< !-- 定义事务所在的bean --> 70< bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager"> 71< property name="sessionFactory" ref="sessionFactory"> < /property> 72< /bean> 73< !-- 定义事务的属性 --> 74< tx:advice id="txAdvice" transaction-manager="transactionManager"> 75< tx:attributes> 76< !-- read-only="true" 事务隔离级别最低,性能最高 --> 77< tx:method name="list*" read-only="true"/> 78< tx:method name="find*" read-only="true"/> 79< tx:method name="get*" read-only="true"/> 80< !-- 除了上面定义的方法之外,其他方法都要通过事务处理 --> 81< tx:method name="*"/> 82< /tx:attributes> 83< /tx:advice> 84< !-- 定义事务所使用的切入点 --> 85< aop:config> 86< aop:pointcut expression="execution(* com.hnqy.service.impl.*.*(..))" id="pointcut"/> 87< aop:advisor advice-ref="txAdvice" pointcut-ref="pointcut"/> 88< /aop:config> 89< !-- 导入SSH创建bean的文件--> 90< import resource="bean.xml"/> 91 < /beans>

(附带web.xml配置)

1 < ?xml version="1.0" encoding="UTF-8"?> 2 < web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> 3< display-name> store< /display-name> 4< welcome-file-list> 5< welcome-file> index.html< /welcome-file> 6< welcome-file> index.htm< /welcome-file> 7< welcome-file> index.jsp< /welcome-file> 8 9< /welcome-file-list> 10< !-- filter过滤器,控制session在view中打开、关闭一定要放到struts的filter上面--> 11< filter> 12< filter-name> OpenSessionInViewFilter< /filter-name> 13< filter-class> org.springframework.orm.hibernate5.support.OpenSessionInViewFilter< /filter-class> 14< /filter> 15< filter-mapping> 16< filter-name> OpenSessionInViewFilter< /filter-name> 17< url-pattern> /*< /url-pattern> 18< /filter-mapping> 19 20< !-- 配置struts的核心过滤器 --> 21< filter> 22< filter-name> struts2< /filter-name> 23< filter-class> org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter< /filter-class> 24< /filter> 25< filter-mapping> 26< filter-name> struts2< /filter-name> 27< url-pattern> *.action< /url-pattern> 28< /filter-mapping> 29< !-- 应用启动加载spring配置文件指定配置文件位置--> 30< context-param> 31< param-name> contextConfigLocation< /param-name> 32< param-value> classpath:beans.xml< /param-value> 33< /context-param> 34< !-- 配置spring的监听器 --> 35< listener> 36< listener-class> org.springframework.web.context.ContextLoaderListener< /listener-class> 37< /listener> 38 < /web-app>

 
【ssh中的application.xml配置】 






    推荐阅读